Previous 199869 Revisions Next

r23314 Friday 31st May, 2013 at 13:25:05 UTC by Fabio Priuli
(MESS) gba.c: reduced the number of per-pixel checks in the new routines. nw.
[src/mess/includes]gba.h
[src/mess/video]gba.c

trunk/src/mess/includes/gba.h
r23313r23314
263263
264264   inline int is_in_window(int x, int window);
265265
266   inline void update_mask(UINT8* mask, int mode, int submode, UINT32* obj_win, UINT8 inwin0, UINT8 inwin1, UINT8 in0_mask, UINT8 in1_mask, UINT8 out_mask);
266267   void draw_modes(int mode, int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
267268   
268269protected:
trunk/src/mess/video/gba.c
r23313r23314
4545#define GBA_SUBMODE1    1
4646#define GBA_SUBMODE2    2
4747
48inline void gba_state::update_mask(UINT8* mask, int mode, int submode, UINT32* obj_win, UINT8 inwin0, UINT8 inwin1, UINT8 in0_mask, UINT8 in1_mask, UINT8 out_mask)
49{
50   UINT8 mode_mask = 0;
51   if (submode == GBA_SUBMODE2)
52   {
53      for (int x = 0; x < 240; x++)
54      {
55         mask[x] = out_mask;
56         
57         if ((obj_win[x] & 0x80000000) == 0)
58            mask[x] = m_WINOUT >> 8;
59         
60         if (inwin1)
61         {
62            if (is_in_window(x, 1))
63               mask[x] = in1_mask;
64         }
65         
66         if (inwin0)
67         {
68            if (is_in_window(x, 0))
69               mask[x] = in0_mask;
70         }
71      }
72   }
73
74   if (mode == GBA_MODE1)
75   {
76      // disable line3
77      mode_mask = ~0x08;
78   }
79   else if (mode == GBA_MODE2)
80   {
81      // disable line0 & line1
82      mode_mask = ~0x03;
83   }
84   else if (mode == GBA_MODE345)
85   {
86      // disable line0, line1 & line3
87      mode_mask = ~0x0b;
88   }
89
90   
91   if (mode_mask)
92   {
93      for (int x = 0; x < 240; x++)
94         mask[x] &= mode_mask;
95   }
96}
97
4898void gba_state::draw_modes(int mode, int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
4999{
50100   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
r23313r23314
53103   UINT8 inWin0Mask = m_WININ & 0x00ff;
54104   UINT8 inWin1Mask = m_WININ >> 8;
55105   UINT8 outMask = m_WINOUT & 0x00ff;
106   UINT8 masks[240];   // this puts together WinMasks with the fact that some modes/submodes skip specific layers!
56107   
57108   if (submode == GBA_SUBMODE2)
58109   {
r23313r23314
108159   draw_gba_oam(lineOBJ, y);
109160   if (submode == GBA_SUBMODE2)
110161      draw_gba_oam_window(lineOBJWin, y);
162
163   memset(masks, 0xff, sizeof(masks));
164   update_mask(&masks[0], mode, submode, lineOBJWin, inWindow0, inWindow1, inWin0Mask, inWin1Mask, outMask);
111165   
112166   for (int x = 0; x < 240; x++)
113167   {
114168      UINT32 color = backdrop;
115169      UINT8 top = 0x20;
116      UINT8 mask = outMask;
117170     
118      if (submode == GBA_SUBMODE2)
171      if ((UINT8)(line0[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x01)
119172      {
120         if ((lineOBJWin[x] & 0x80000000) == 0)
121            mask = m_WINOUT >> 8;
122         
123         if (inWindow1)
124         {
125            if (is_in_window(x, 1))
126               mask = inWin1Mask;
127         }
128         
129         if (inWindow0)
130         {
131            if (is_in_window(x, 0))
132               mask = inWin0Mask;
133         }
134         
173         color = line0[x];
174         top = 0x01;
135175      }
136176     
137      if (mode == GBA_MODE0 || mode == GBA_MODE1)
138         if ((UINT8)(line0[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x01)))
139         {
140            color = line0[x];
141            top = 0x01;
142         }
177      if ((UINT8)(line1[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x02)
178      {
179         color = line1[x];
180         top = 0x02;
181      }
143182     
144      if (mode == GBA_MODE0 || mode == GBA_MODE1)
145         if ((UINT8)(line1[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x02)))
146         {
147            color = line1[x];
148            top = 0x02;
149         }
183      if ((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x04)
184      {
185         color = line2[x];
186         top = 0x04;
187      }
150188     
151      if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345)
152         if ((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x04)))
153         {
154            color = line2[x];
155            top = 0x04;
156         }
189      if ((UINT8)(line3[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x08)
190      {
191         color = line3[x];
192         top = 0x08;
193      }
157194     
158      if (mode == GBA_MODE0 || mode == GBA_MODE2)
159         if ((UINT8)(line3[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x08)))
160         {
161            color = line3[x];
162            top = 0x08;
163         }
195      if ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24) && masks[x] & 0x10)
196      {
197         color = lineOBJ[x];
198         top = 0x10;
199      }
164200     
165      if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345)
166         if ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x10)))
167         {
168            color = lineOBJ[x];
169            top = 0x10;
170         }
171     
172201      if (color & 0x00010000)
173202      {
174         if ((submode == GBA_SUBMODE0 && top == 0x10) || submode == GBA_SUBMODE1 || submode == GBA_SUBMODE2)
203         if (submode != GBA_SUBMODE0 || top == 0x10)
175204         {
176205            UINT32 back = backdrop;
177206            UINT8 top2 = 0x20;
178207           
179            if (mode == GBA_MODE0 || mode == GBA_MODE1)
180               if ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x01)))
181               {
182                  back = line0[x];
183                  top2 = 0x01;
184               }
208            if ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x01)
209            {
210               back = line0[x];
211               top2 = 0x01;
212            }
185213           
186            if (mode == GBA_MODE0 || mode == GBA_MODE1)
187               if ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x02)))
188               {
189                  back = line1[x];
190                  top2 = 0x02;
191               }
214            if ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x02)
215            {
216               back = line1[x];
217               top2 = 0x02;
218            }
192219           
193            if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345)
194               if ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x04)))
195               {
196                  back = line2[x];
197                  top2 = 0x04;
198               }
220            if ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x04)
221            {
222               back = line2[x];
223               top2 = 0x04;
224            }
199225           
200            if (mode == GBA_MODE0 || mode == GBA_MODE2)
201               if ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x08)))
202               {
203                  back = line3[x];
204                  top2 = 0x08;
205               }
226            if ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x08)
227            {
228               back = line3[x];
229               top2 = 0x08;
230            }
206231           
207232            if (top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
208233               color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
r23313r23314
223248            }
224249         }
225250      }
226      else if (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x20))
251      else if (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && masks[x] & 0x20))
227252      {
228253         if (top & m_BLDCNT)
229254         {
r23313r23314
236261                  UINT32 back = backdrop;
237262                  UINT8 top2 = 0x20;
238263                 
239                  if (mode == GBA_MODE0 || mode == GBA_MODE1)
240                     if ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x01)))
264                  if ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x01)
265                  {
266                     if (top != 0x01)
241267                     {
242                        if (top != 0x01)
243                        {
244                           back = line0[x];
245                           top2 = 0x01;
246                        }
268                        back = line0[x];
269                        top2 = 0x01;
247270                     }
271                  }
248272                 
249                  if (mode == GBA_MODE0 || mode == GBA_MODE1)
250                     if ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x02)))
273                  if ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x02)
274                  {
275                     if (top != 0x02)
251276                     {
252                        if (top != 0x02)
253                        {
254                           back = line1[x];
255                           top2 = 0x02;
256                        }
277                        back = line1[x];
278                        top2 = 0x02;
257279                     }
280                  }
258281                 
259                  if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345)
260                     if ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x04)))
282                  if ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x04)
283                  {
284                     if (top != 0x04)
261285                     {
262                        if (top != 0x04)
263                        {
264                           back = line2[x];
265                           top2 = 0x04;
266                        }
286                        back = line2[x];
287                        top2 = 0x04;
267288                     }
289                  }
268290                 
269                  if (mode == GBA_MODE0 || mode == GBA_MODE2)
270                     if ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x08)))
291                  if ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x08)
292                  {
293                     if (top != 0x08)
271294                     {
272                        if (top != 0x08)
273                        {
274                           back = line3[x];
275                           top2 = 0x08;
276                        }
295                        back = line3[x];
296                        top2 = 0x08;
277297                     }
298                  }
278299                 
279                  if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345)
280                     if ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x10)))
300                  if ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24) && masks[x] & 0x10)
301                  {
302                     if (top != 0x10)
281303                     {
282                        if (top != 0x10)
283                        {
284                           back = lineOBJ[x];
285                           top2 = 0x10;
286                        }
304                        back = lineOBJ[x];
305                        top2 = 0x10;
287306                     }
307                  }
288308                 
289309                  if (top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
290310                     color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
r23313r23314
18521872      case 3:
18531873      case 4:
18541874      case 5:
1855         draw_modes( m_DISPCNT & 7, submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], depth);
1875         draw_modes(m_DISPCNT & 7, submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], depth);
18561876         break;
18571877      default:
1858         fatalerror( "Invalid screen mode (6 or 7)!\n" );
1878         fatalerror("Invalid screen mode (6 or 7)!\n");
18591879         break;
18601880   }
1861
1881   
18621882   for (int x = 0; x < 240; x++)
18631883   {
18641884      scanline[x] = m_xferscan[6][1024 + x] & 0x7fff;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team