@@ -117,11 +117,26 @@ bool Renderer::ExecuteDCPInstruction(const uint32_t instruction) noexcept
117117 return false ;
118118 }
119119
120- if constexpr (PLANE == A) // Plane A-only instructions.
120+ // Common instructions.
121+ switch (code)
121122 {
122- switch (code)
123+ case NoOperation:
124+ case LoadControlTableLineStartPointer: // Avoid going in the default case.
125+ case LoadDisplayLineStartPointer:
126+ break ;
127+
128+ case SignalScanLine: // Signal when scan reaches this line.
129+ return true ;
130+
131+ case LoadDisplayParameters: // Load display parameters.
132+ m_imageType[PLANE] = decodeImageType (bits<0 , 1 >(instruction));
133+ m_pixelRepeatFactor[PLANE] = 1 << (1 + bits<2 , 3 >(instruction));
134+ m_bps[PLANE] = decodeBitsPerPixel (bits<8 , 9 >(instruction));
135+ break ;
136+
137+ case SelectImageCodingMethod: // Select image coding methods.
138+ if constexpr (PLANE == A)
123139 {
124- case SelectImageCodingMethod: // Select image coding methods.
125140 m_clutSelectHigh = bit<22 >(instruction);
126141 m_matteNumber = bit<19 >(instruction);
127142 m_codingMethod[B] = decodeCodingMethod1 (bits<8 , 11 >(instruction));
@@ -131,91 +146,87 @@ bool Renderer::ExecuteDCPInstruction(const uint32_t instruction) noexcept
131146 static_cast <int >(m_codingMethod[A]), static_cast <int >(m_codingMethod[B]));
132147 // TODO: what to do with external video enabled?
133148 m_externalVideo = bit<18 >(instruction);
134- return false ;
149+ }
150+ return false ;
135151
136- case LoadTransparencyControl: // Load transparency control information.
152+ case LoadTransparencyControl: // Load transparency control information.
153+ if constexpr (PLANE == A)
154+ {
137155 m_mix = !bit<23 >(instruction);
138156 m_transparencyControl[B] = bits<8 , 11 >(instruction);
139157 m_transparencyControl[A] = bits<0 , 3 >(instruction);
140- return false ;
158+ }
159+ return false ;
141160
142- case LoadPlaneOrder: // Load plane order.
161+ case LoadPlaneOrder: // Load plane order.
162+ if constexpr (PLANE == A)
143163 m_planeOrder = bit<0 >(instruction);
144- return false ;
164+ return false ;
165+
166+ case SetCLUTBank: // Set CLUT bank.
167+ m_clutBank = bits<0 , 1 >(instruction);
168+ break ;
145169
146- case LoadTransparentColorA: // Load transparent color for plane A.
170+ case LoadTransparentColorA: // Load transparent color for plane A.
171+ if constexpr (PLANE == A)
147172 m_transparentColorRgb[A] = dcpExtractCommand (instruction);
148- return false ;
173+ return false ;
174+
175+ case LoadTransparentColorB: // Load transparent color for plane B.
176+ if constexpr (PLANE == B)
177+ m_transparentColorRgb[B] = dcpExtractCommand (instruction);
178+ return false ;
149179
150- case LoadMaskColorA: // Load mask color for plane A.
180+ case LoadMaskColorA: // Load mask color for plane A.
181+ if constexpr (PLANE == A)
151182 m_maskColorRgb[A] = dcpExtractCommand (instruction);
152- return false ;
183+ return false ;
153184
154- case LoadDYUVStartValueA: // Load DYUV start value for plane A.
185+ case LoadMaskColorB: // Load mask color for plane B.
186+ if constexpr (PLANE == B)
187+ m_maskColorRgb[B] = dcpExtractCommand (instruction);
188+ return false ;
189+
190+ case LoadDYUVStartValueA: // Load DYUV start value for plane A.
191+ if constexpr (PLANE == A)
155192 m_dyuvInitialValue[A] = dcpExtractCommand (instruction);
156- return false ;
193+ return false ;
157194
158- case LoadBackdropColor: // Load backdrop color.
195+ case LoadDYUVStartValueB: // Load DYUV start value for plane B.
196+ if constexpr (PLANE == B)
197+ m_dyuvInitialValue[B] = dcpExtractCommand (instruction);
198+ return false ;
199+
200+ case LoadBackdropColor: // Load backdrop color.
201+ if constexpr (PLANE == A)
159202 m_backdropColor = bits<0 , 3 >(instruction);
160- return false ;
203+ return false ;
161204
162- case LoadMosaicFactorA: // Load mosaic pixel hold factor for A.
205+ case LoadMosaicFactorA: // Load mosaic pixel hold factor for A.
206+ if constexpr (PLANE == A)
207+ {
163208 m_holdEnabled[A] = bit<23 >(instruction);
164209 m_holdFactor[A] = instruction;
165- return false ;
166-
167- case LoadImageContributionFactorA: // Load image contribution factor for A.
168- m_icf[A] = bits<0 , 5 >(instruction);
169- return false ;
170210 }
171- }
172- else // Plane B-only instructions.
173- {
174- switch (code)
175- {
176- case LoadTransparentColorB: // Load transparent color for plane B.
177- m_transparentColorRgb[B] = dcpExtractCommand (instruction);
178- return false ;
179-
180- case LoadMaskColorB: // Load mask color for plane B.
181- m_maskColorRgb[B] = dcpExtractCommand (instruction);
182- return false ;
183-
184- case LoadDYUVStartValueB: // Load DYUV start value for plane B.
185- m_dyuvInitialValue[B] = dcpExtractCommand (instruction);
186- return false ;
211+ return false ;
187212
188- case LoadMosaicFactorB: // Load mosaic pixel hold factor for B.
213+ case LoadMosaicFactorB: // Load mosaic pixel hold factor for B.
214+ if constexpr (PLANE == B)
215+ {
189216 m_holdEnabled[B] = bit<23 >(instruction);
190217 m_holdFactor[B] = instruction;
191- return false ;
192-
193- case LoadImageContributionFactorB: // Load image contribution factor for B.
194- m_icf[B] = bits<0 , 5 >(instruction);
195- return false ;
196218 }
197- }
198-
199- // Common instructions.
200- switch (code)
201- {
202- case NoOperation:
203- case LoadControlTableLineStartPointer: // Avoid going in the default case.
204- case LoadDisplayLineStartPointer:
205- break ;
206-
207- case SignalScanLine: // Signal when scan reaches this line.
208- return true ;
219+ return false ;
209220
210- case LoadDisplayParameters: // Load display parameters.
211- m_imageType[PLANE] = decodeImageType (bits<0 , 1 >(instruction));
212- m_pixelRepeatFactor[PLANE] = 1 << (1 + bits<2 , 3 >(instruction));
213- m_bps[PLANE] = decodeBitsPerPixel (bits<8 , 9 >(instruction));
214- break ;
221+ case LoadImageContributionFactorA: // Load image contribution factor for A.
222+ if constexpr (PLANE == A)
223+ m_icf[A] = bits<0 , 5 >(instruction);
224+ return false ;
215225
216- case SetCLUTBank: // Set CLUT bank.
217- m_clutBank = bits<0 , 1 >(instruction);
218- break ;
226+ case LoadImageContributionFactorB: // Load image contribution factor for B.
227+ if constexpr (PLANE == B)
228+ m_icf[B] = bits<0 , 5 >(instruction);
229+ return false ;
219230
220231 default :
221232 std::println (stderr, " Unknow DCP instruction {:#X}" , instruction);
0 commit comments