Previous 199869 Revisions Next

r23153 Saturday 25th May, 2013 at 13:54:08 UTC by Fabio Priuli
(MESS) gba: modernized the video (i.e. moved variables inside the state class). nw.
[src/mess/drivers]gba.c
[src/mess/includes]gba.h
[src/mess/video]gba.c gbam345.c gbamode0.c gbamode1.c gbamode2.c

trunk/src/mess/drivers/gba.c
r23152r23153
1818#include "cpu/arm7/arm7.h"
1919#include "cpu/arm7/arm7core.h"
2020#include "sound/dac.h"
21#include "machine/intelfsh.h"
2221#include "audio/gb.h"
2322#include "includes/gba.h"
2423#include "machine/gba_rom.h"
r23152r23153
19511950   // draw only visible scanlines
19521951   if (scanline < 160)
19531952   {
1954      gba_draw_scanline(machine(), scanline);
1953      draw_scanline(scanline);
19551954   }
19561955   m_DISPSTAT |= DISPSTAT_HBL;
19571956   if ((m_DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0)
trunk/src/mess/video/gbamode0.c
r23152r23153
1   /***************************************************************************
1/***************************************************************************
22
33   gbamode0.c
44
r23152r23153
88
99***************************************************************************/
1010
11static void draw_mode0_scanline(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
11
12void gba_state::draw_mode0(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
1213{
14   switch (submode)
15   {
16      case 0:
17         draw_mode0_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
18         break;
19      case 1:
20         draw_mode0_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
21         break;
22      case 2:
23         draw_mode0_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
24         break;
25   }
26}
27
28void gba_state::draw_mode0_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
29{
1330   int x = 0;
14   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
31   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
1532
16   draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS);
17   draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS);
18   draw_bg_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2HOFS, state->m_BG2VOFS);
19   draw_bg_scanline(state, line3, y, DISPCNT_BG3_EN, state->m_BG3CNT, state->m_BG3HOFS, state->m_BG3VOFS);
20   draw_gba_oam(state, machine, lineOBJ, y);
33   draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
34   draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
35   draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS);
36   draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS);
37   draw_gba_oam(lineOBJ, y);
2138
2239   for(x = 0; x < 240; x++)
2340   {
r23152r23153
83100            top2 = 0x08;
84101         }
85102
86         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
103         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
87104         {
88            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
105            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
89106         }
90107         else
91108         {
92            switch(state->m_BLDCNT & BLDCNT_SFX)
109            switch(m_BLDCNT & BLDCNT_SFX)
93110            {
94111               case BLDCNT_SFX_LIGHTEN:
95                  if(top & state->m_BLDCNT)
112                  if(top & m_BLDCNT)
96113                  {
97                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
114                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
98115                  }
99116                  break;
100117               case BLDCNT_SFX_DARKEN:
101                  if(top & state->m_BLDCNT)
118                  if(top & m_BLDCNT)
102119                  {
103                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
120                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
104121                  }
105122                  break;
106123            }
r23152r23153
111128   }
112129}
113130
114static void draw_mode0_scanline_nowindow(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
131void gba_state::draw_mode0_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
115132{
116133   int x = 0;
117   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
118   int effect = state->m_BLDCNT & BLDCNT_SFX;
134   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
135   int effect = m_BLDCNT & BLDCNT_SFX;
119136
120   draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS);
121   draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS);
122   draw_bg_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2HOFS, state->m_BG2VOFS);
123   draw_bg_scanline(state, line3, y, DISPCNT_BG3_EN, state->m_BG3CNT, state->m_BG3HOFS, state->m_BG3VOFS);
124   draw_gba_oam(state, machine, lineOBJ, y);
137   draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
138   draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
139   draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS);
140   draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS);
141   draw_gba_oam(lineOBJ, y);
125142
126143   for(x = 0; x < 240; x++)
127144   {
r23152r23153
165182            case BLDCNT_SFX_NONE:
166183               break;
167184            case BLDCNT_SFX_ALPHA:
168               if(state->m_BLDCNT & top)
185               if(m_BLDCNT & top)
169186               {
170187                  UINT32 back = backdrop;
171188                  UINT8 top2 = 0x20;
r23152r23153
215232                     }
216233                  }
217234
218                  if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
235                  if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
219236                  {
220                     color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
237                     color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
221238                  }
222239               }
223240               break;
224241            case BLDCNT_SFX_LIGHTEN:
225               if(top & state->m_BLDCNT)
242               if(top & m_BLDCNT)
226243               {
227                  color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
244                  color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
228245               }
229246               break;
230247            case BLDCNT_SFX_DARKEN:
231               if(top & state->m_BLDCNT)
248               if(top & m_BLDCNT)
232249               {
233                  color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
250                  color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
234251               }
235252               break;
236253         }
r23152r23153
264281            top2 = 0x08;
265282         }
266283
267         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
284         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
268285         {
269            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
286            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
270287         }
271288         else
272289         {
273            switch(state->m_BLDCNT & BLDCNT_SFX)
290            switch(m_BLDCNT & BLDCNT_SFX)
274291            {
275292               case BLDCNT_SFX_LIGHTEN:
276                  if(top & state->m_BLDCNT)
293                  if(top & m_BLDCNT)
277294                  {
278                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
295                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
279296                  }
280297                  break;
281298               case BLDCNT_SFX_DARKEN:
282                  if(top & state->m_BLDCNT)
299                  if(top & m_BLDCNT)
283300                  {
284                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
301                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
285302                  }
286303                  break;
287304            }
r23152r23153
291308   }
292309}
293310
294static void draw_mode0_scanline_all(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
311void gba_state::draw_mode0_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
295312{
296313   int x = 0;
297   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
314   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
298315   int inWindow0 = 0;
299316   int inWindow1 = 0;
300   UINT8 inWin0Mask = state->m_WININ & 0x00ff;
301   UINT8 inWin1Mask = state->m_WININ >> 8;
302   UINT8 outMask = state->m_WINOUT & 0x00ff;
317   UINT8 inWin0Mask = m_WININ & 0x00ff;
318   UINT8 inWin1Mask = m_WININ >> 8;
319   UINT8 outMask = m_WINOUT & 0x00ff;
303320
304   if(state->m_DISPCNT & DISPCNT_WIN0_EN)
321   if(m_DISPCNT & DISPCNT_WIN0_EN)
305322   {
306      UINT8 v0 = state->m_WIN0V >> 8;
307      UINT8 v1 = state->m_WIN0V & 0x00ff;
323      UINT8 v0 = m_WIN0V >> 8;
324      UINT8 v1 = m_WIN0V & 0x00ff;
308325      inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
309326      if(v1 >= v0)
310327      {
r23152r23153
316333      }
317334   }
318335
319   if(state->m_DISPCNT & DISPCNT_WIN1_EN)
336   if(m_DISPCNT & DISPCNT_WIN1_EN)
320337   {
321      UINT8 v0 = state->m_WIN1V >> 8;
322      UINT8 v1 = state->m_WIN1V & 0x00ff;
338      UINT8 v0 = m_WIN1V >> 8;
339      UINT8 v1 = m_WIN1V & 0x00ff;
323340      inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
324341      if(v1 >= v0)
325342      {
r23152r23153
331348      }
332349   }
333350
334   draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS);
335   draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS);
336   draw_bg_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2HOFS, state->m_BG2VOFS);
337   draw_bg_scanline(state, line3, y, DISPCNT_BG3_EN, state->m_BG3CNT, state->m_BG3HOFS, state->m_BG3VOFS);
338   draw_gba_oam(state, machine, lineOBJ, y);
339   draw_gba_oam_window(state, machine, lineOBJWin, y);
351   draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
352   draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
353   draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS);
354   draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS);
355   draw_gba_oam(lineOBJ, y);
356   draw_gba_oam_window(lineOBJWin, y);
340357
341358   for(x = 0; x < 240; x++)
342359   {
r23152r23153
346363
347364      if((lineOBJWin[x] & 0x80000000) == 0)
348365      {
349         mask = state->m_WINOUT >> 8;
366         mask = m_WINOUT >> 8;
350367      }
351368
352369      if(inWindow1)
353370      {
354         if(is_in_window(state, x, 1))
371         if(is_in_window(x, 1))
355372         {
356373            mask = inWin1Mask;
357374         }
r23152r23153
359376
360377      if(inWindow0)
361378      {
362         if(is_in_window(state, x, 0))
379         if(is_in_window(x, 0))
363380         {
364381            mask = inWin0Mask;
365382         }
r23152r23153
399416      {
400417         if((color & 0x00010000) == 0)
401418         {
402            switch(state->m_BLDCNT & BLDCNT_SFX)
419            switch(m_BLDCNT & BLDCNT_SFX)
403420            {
404421               case BLDCNT_SFX_NONE:
405422                  break;
406423               case BLDCNT_SFX_ALPHA:
407424               {
408                  if(top & state->m_BLDCNT)
425                  if(top & m_BLDCNT)
409426                  {
410427                     UINT32 back = backdrop;
411428                     UINT8 top2 = 0x20;
r23152r23153
454471                        }
455472                     }
456473
457                     if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
474                     if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
458475                     {
459                        color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
476                        color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
460477                     }
461478                  }
462479                  break;
463480               }
464481               case BLDCNT_SFX_LIGHTEN:
465                  if(top & state->m_BLDCNT)
482                  if(top & m_BLDCNT)
466483                  {
467                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
484                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
468485                  }
469486                  break;
470487               case BLDCNT_SFX_DARKEN:
471                  if(top & state->m_BLDCNT)
488                  if(top & m_BLDCNT)
472489                  {
473                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
490                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
474491                  }
475492                  break;
476493            }
r23152r23153
504521               top2 = 0x08;
505522            }
506523
507            if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
524            if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
508525            {
509               color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
526               color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
510527            }
511528            else
512529            {
513               switch(state->m_BLDCNT & BLDCNT_SFX)
530               switch(m_BLDCNT & BLDCNT_SFX)
514531               {
515532                  case BLDCNT_SFX_LIGHTEN:
516                     if(top & state->m_BLDCNT)
533                     if(top & m_BLDCNT)
517534                     {
518                        color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
535                        color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
519536                     }
520537                     break;
521538                  case BLDCNT_SFX_DARKEN:
522                     if(top & state->m_BLDCNT)
539                     if(top & m_BLDCNT)
523540                     {
524                        color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
541                        color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
525542                     }
526543                     break;
527544               }
r23152r23153
557574            top2 = 0x08;
558575         }
559576
560         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
577         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
561578         {
562            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
579            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
563580         }
564581         else
565582         {
566            switch(state->m_BLDCNT & BLDCNT_SFX)
583            switch(m_BLDCNT & BLDCNT_SFX)
567584            {
568585               case BLDCNT_SFX_LIGHTEN:
569                  if(top & state->m_BLDCNT)
586                  if(top & m_BLDCNT)
570587                  {
571                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
588                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
572589                  }
573590                  break;
574591               case BLDCNT_SFX_DARKEN:
575                  if(top & state->m_BLDCNT)
592                  if(top & m_BLDCNT)
576593                  {
577                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
594                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
578595                  }
579596                  break;
580597            }
trunk/src/mess/video/gbam345.c
r23152r23153
1   /***************************************************************************
1/***************************************************************************
22
33   gbam345.c
44
r23152r23153
88
99***************************************************************************/
1010
11static void draw_roz_bitmap_mode_scanline(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
11
12void gba_state::draw_mode345(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
1213{
14   switch (submode)
15   {
16      case 0:
17         draw_roz_bitmap_mode_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
18         break;
19      case 1:
20         draw_roz_bitmap_mode_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
21         break;
22      case 2:
23         draw_roz_bitmap_mode_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
24         break;
25   }
26}
27
28void gba_state::draw_roz_bitmap_mode_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
29{
1330   int x = 0;
14   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
31   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
1532
16   draw_roz_bitmap_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed, bpp);
17   draw_gba_oam(state, machine, lineOBJ, y);
33   draw_roz_bitmap_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed, bpp);
34   draw_gba_oam(lineOBJ, y);
1835
1936   for(x = 0; x < 240; x++)
2037   {
r23152r23153
4461            top2 = 0x04;
4562         }
4663
47         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
64         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
4865         {
49            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
66            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
5067         }
5168         else
5269         {
53            switch(state->m_BLDCNT & BLDCNT_SFX)
70            switch(m_BLDCNT & BLDCNT_SFX)
5471            {
5572               case BLDCNT_SFX_LIGHTEN:
56                  if(top & state->m_BLDCNT)
73                  if(top & m_BLDCNT)
5774                  {
58                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
75                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
5976                  }
6077                  break;
6178               case BLDCNT_SFX_DARKEN:
62                  if(top & state->m_BLDCNT)
79                  if(top & m_BLDCNT)
6380                  {
64                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
81                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
6582                  }
6683                  break;
6784            }
r23152r23153
7087
7188      lineMix[x] = color;
7289   }
73   state->m_gfxBG2Changed = 0;
90   m_gfxBG2Changed = 0;
7491}
7592
76static void draw_roz_bitmap_mode_scanline_nowindow(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
93void gba_state::draw_roz_bitmap_mode_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
7794{
7895   int x = 0;
79   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
80   int effect = state->m_BLDCNT & BLDCNT_SFX;
96   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
97   int effect = m_BLDCNT & BLDCNT_SFX;
8198
82   draw_roz_bitmap_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed, bpp);
83   draw_gba_oam(state, machine, lineOBJ, y);
99   draw_roz_bitmap_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed, bpp);
100   draw_gba_oam(lineOBJ, y);
84101
85102   for(x = 0; x < 240; x++)
86103   {
r23152r23153
106123            case BLDCNT_SFX_NONE:
107124               break;
108125            case BLDCNT_SFX_ALPHA:
109               if(state->m_BLDCNT & top)
126               if(m_BLDCNT & top)
110127               {
111128                  UINT32 back = backdrop;
112129                  UINT8 top2 = 0x20;
r23152r23153
129146                     }
130147                  }
131148
132                  if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
149                  if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
133150                  {
134                     color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
151                     color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
135152                  }
136153               }
137154               break;
138155            case BLDCNT_SFX_LIGHTEN:
139               if(top & state->m_BLDCNT)
156               if(top & m_BLDCNT)
140157               {
141                  color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
158                  color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
142159               }
143160               break;
144161            case BLDCNT_SFX_DARKEN:
145               if(top & state->m_BLDCNT)
162               if(top & m_BLDCNT)
146163               {
147                  color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
164                  color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
148165               }
149166               break;
150167         }
r23152r23153
160177            top2 = 0x04;
161178         }
162179
163         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
180         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
164181         {
165            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
182            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
166183         }
167184         else
168185         {
169            switch(state->m_BLDCNT & BLDCNT_SFX)
186            switch(m_BLDCNT & BLDCNT_SFX)
170187            {
171188               case BLDCNT_SFX_LIGHTEN:
172                  if(top & state->m_BLDCNT)
189                  if(top & m_BLDCNT)
173190                  {
174                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
191                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
175192                  }
176193                  break;
177194               case BLDCNT_SFX_DARKEN:
178                  if(top & state->m_BLDCNT)
195                  if(top & m_BLDCNT)
179196                  {
180                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
197                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
181198                  }
182199                  break;
183200            }
r23152r23153
185202      }
186203      lineMix[x] = color;
187204   }
188   state->m_gfxBG2Changed = 0;
205   m_gfxBG2Changed = 0;
189206}
190207
191static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
208void gba_state::draw_roz_bitmap_mode_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
192209{
193210   int x = 0;
194   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
211   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
195212   int inWindow0 = 0;
196213   int inWindow1 = 0;
197   UINT8 inWin0Mask = state->m_WININ & 0x00ff;
198   UINT8 inWin1Mask = state->m_WININ >> 8;
199   UINT8 outMask = state->m_WINOUT & 0x00ff;
214   UINT8 inWin0Mask = m_WININ & 0x00ff;
215   UINT8 inWin1Mask = m_WININ >> 8;
216   UINT8 outMask = m_WINOUT & 0x00ff;
200217
201   if(state->m_DISPCNT & DISPCNT_WIN0_EN)
218   if(m_DISPCNT & DISPCNT_WIN0_EN)
202219   {
203      UINT8 v0 = state->m_WIN0V >> 8;
204      UINT8 v1 = state->m_WIN0V & 0x00ff;
220      UINT8 v0 = m_WIN0V >> 8;
221      UINT8 v1 = m_WIN0V & 0x00ff;
205222      inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
206223      if(v1 >= v0)
207224      {
r23152r23153
213230      }
214231   }
215232
216   if(state->m_DISPCNT & DISPCNT_WIN1_EN)
233   if(m_DISPCNT & DISPCNT_WIN1_EN)
217234   {
218      UINT8 v0 = state->m_WIN1V >> 8;
219      UINT8 v1 = state->m_WIN1V & 0x00ff;
235      UINT8 v0 = m_WIN1V >> 8;
236      UINT8 v1 = m_WIN1V & 0x00ff;
220237      inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
221238      if(v1 >= v0)
222239      {
r23152r23153
228245      }
229246   }
230247
231   draw_roz_bitmap_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed, bpp);
232   draw_gba_oam(state, machine, lineOBJ, y);
233   draw_gba_oam_window(state, machine, lineOBJWin, y);
248   draw_roz_bitmap_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed, bpp);
249   draw_gba_oam(lineOBJ, y);
250   draw_gba_oam_window(lineOBJWin, y);
234251
235252   for(x = 0; x < 240; x++)
236253   {
r23152r23153
240257
241258      if((lineOBJWin[x] & 0x80000000) == 0)
242259      {
243         mask = state->m_WINOUT >> 8;
260         mask = m_WINOUT >> 8;
244261      }
245262
246263      if(inWindow1)
247264      {
248         if(is_in_window(state, x, 1))
265         if(is_in_window(x, 1))
249266         {
250267            mask = inWin1Mask;
251268         }
r23152r23153
253270
254271      if(inWindow0)
255272      {
256         if(is_in_window(state, x, 0))
273         if(is_in_window(x, 0))
257274         {
258275            mask = inWin0Mask;
259276         }
r23152r23153
275292      {
276293         if((color & 0x00010000) == 0)
277294         {
278            switch(state->m_BLDCNT & BLDCNT_SFX)
295            switch(m_BLDCNT & BLDCNT_SFX)
279296            {
280297               case BLDCNT_SFX_NONE:
281298                  break;
282299               case BLDCNT_SFX_ALPHA:
283300               {
284                  if(top & state->m_BLDCNT)
301                  if(top & m_BLDCNT)
285302                  {
286303                     UINT32 back = backdrop;
287304                     UINT8 top2 = 0x20;
r23152r23153
303320                        }
304321                     }
305322
306                     if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
323                     if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
307324                     {
308                        color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
325                        color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
309326                     }
310327                  }
311328                  break;
312329               }
313330               case BLDCNT_SFX_LIGHTEN:
314                  if(top & state->m_BLDCNT)
331                  if(top & m_BLDCNT)
315332                  {
316                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
333                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
317334                  }
318335                  break;
319336               case BLDCNT_SFX_DARKEN:
320                  if(top & state->m_BLDCNT)
337                  if(top & m_BLDCNT)
321338                  {
322                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
339                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
323340                  }
324341                  break;
325342            }
r23152r23153
335352               top2 = 0x04;
336353            }
337354
338            if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
355            if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
339356            {
340               color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
357               color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
341358            }
342359            else
343360            {
344               switch(state->m_BLDCNT & BLDCNT_SFX)
361               switch(m_BLDCNT & BLDCNT_SFX)
345362               {
346363                  case BLDCNT_SFX_LIGHTEN:
347                     if(top & state->m_BLDCNT)
364                     if(top & m_BLDCNT)
348365                     {
349                        color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
366                        color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
350367                     }
351368                     break;
352369                  case BLDCNT_SFX_DARKEN:
353                     if(top & state->m_BLDCNT)
370                     if(top & m_BLDCNT)
354371                     {
355                        color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
372                        color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
356373                     }
357374                     break;
358375               }
r23152r23153
370387            top2 = 0x04;
371388         }
372389
373         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
390         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
374391         {
375            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
392            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
376393         }
377394         else
378395         {
379            switch(state->m_BLDCNT & BLDCNT_SFX)
396            switch(m_BLDCNT & BLDCNT_SFX)
380397            {
381398               case BLDCNT_SFX_LIGHTEN:
382                  if(top & state->m_BLDCNT)
399                  if(top & m_BLDCNT)
383400                  {
384                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
401                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
385402                  }
386403                  break;
387404               case BLDCNT_SFX_DARKEN:
388                  if(top & state->m_BLDCNT)
405                  if(top & m_BLDCNT)
389406                  {
390                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
407                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
391408                  }
392409                  break;
393410            }
r23152r23153
395412      }
396413      lineMix[x] = color;
397414   }
398   state->m_gfxBG2Changed = 0;
415   m_gfxBG2Changed = 0;
399416}
trunk/src/mess/video/gbamode1.c
r23152r23153
1   /***************************************************************************
1/***************************************************************************
22
33   gbamode1.c
44
r23152r23153
88
99***************************************************************************/
1010
11static void draw_mode1_scanline(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
11
12void gba_state::draw_mode1(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
1213{
14   switch (submode)
15   {
16      case 0:
17         draw_mode1_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
18         break;
19      case 1:
20         draw_mode1_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
21         break;
22      case 2:
23         draw_mode1_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
24         break;
25   }
26}
27
28void gba_state::draw_mode1_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
29{
1330   int x = 0;
14   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
31   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
1532
16   draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS);
17   draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS);
18   draw_roz_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed);
19   draw_gba_oam(state, machine, lineOBJ, y);
33   draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
34   draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
35   draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed);
36   draw_gba_oam(lineOBJ, y);
2037
2138   for(x = 0; x < 240; x++)
2239   {
r23152r23153
7087            top2 = 0x04;
7188         }
7289
73         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
90         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
7491         {
75            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
92            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
7693         }
7794         else
7895         {
79            switch(state->m_BLDCNT & BLDCNT_SFX)
96            switch(m_BLDCNT & BLDCNT_SFX)
8097            {
8198               case BLDCNT_SFX_LIGHTEN:
82                  if(top & state->m_BLDCNT)
99                  if(top & m_BLDCNT)
83100                  {
84                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
101                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
85102                  }
86103                  break;
87104               case BLDCNT_SFX_DARKEN:
88                  if(top & state->m_BLDCNT)
105                  if(top & m_BLDCNT)
89106                  {
90                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
107                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
91108                  }
92109                  break;
93110            }
r23152r23153
96113
97114      lineMix[x] = color;
98115   }
99   state->m_gfxBG2Changed = 0;
116   m_gfxBG2Changed = 0;
100117}
101118
102static void draw_mode1_scanline_nowindow(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
119void gba_state::draw_mode1_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
103120{
104121   int x = 0;
105   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
106   int effect = state->m_BLDCNT & BLDCNT_SFX;
122   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
123   int effect = m_BLDCNT & BLDCNT_SFX;
107124
108   draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS);
109   draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS);
110   draw_roz_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed);
111   draw_gba_oam(state, machine, lineOBJ, y);
125   draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
126   draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
127   draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed);
128   draw_gba_oam(lineOBJ, y);
112129
113130   for(x = 0; x < 240; x++)
114131   {
r23152r23153
146163            case BLDCNT_SFX_NONE:
147164               break;
148165            case BLDCNT_SFX_ALPHA:
149               if(state->m_BLDCNT & top)
166               if(m_BLDCNT & top)
150167               {
151168                  UINT32 back = backdrop;
152169                  UINT8 top2 = 0x20;
r23152r23153
187204                     }
188205                  }
189206
190                  if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
207                  if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
191208                  {
192                     color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
209                     color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
193210                  }
194211               }
195212               break;
196213            case BLDCNT_SFX_LIGHTEN:
197               if(top & state->m_BLDCNT)
214               if(top & m_BLDCNT)
198215               {
199                  color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
216                  color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
200217               }
201218               break;
202219            case BLDCNT_SFX_DARKEN:
203               if(top & state->m_BLDCNT)
220               if(top & m_BLDCNT)
204221               {
205                  color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
222                  color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
206223               }
207224               break;
208225         }
r23152r23153
230247            top2 = 0x04;
231248         }
232249
233         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
250         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
234251         {
235            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
252            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
236253         }
237254         else
238255         {
239            switch(state->m_BLDCNT & BLDCNT_SFX)
256            switch(m_BLDCNT & BLDCNT_SFX)
240257            {
241258               case BLDCNT_SFX_LIGHTEN:
242                  if(top & state->m_BLDCNT)
259                  if(top & m_BLDCNT)
243260                  {
244                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
261                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
245262                  }
246263                  break;
247264               case BLDCNT_SFX_DARKEN:
248                  if(top & state->m_BLDCNT)
265                  if(top & m_BLDCNT)
249266                  {
250                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
267                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
251268                  }
252269                  break;
253270            }
r23152r23153
255272      }
256273      lineMix[x] = color;
257274   }
258   state->m_gfxBG2Changed = 0;
275   m_gfxBG2Changed = 0;
259276}
260277
261static void draw_mode1_scanline_all(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
278void gba_state::draw_mode1_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
262279{
263280   int x = 0;
264   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
281   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
265282   int inWindow0 = 0;
266283   int inWindow1 = 0;
267   UINT8 inWin0Mask = state->m_WININ & 0x00ff;
268   UINT8 inWin1Mask = state->m_WININ >> 8;
269   UINT8 outMask = state->m_WINOUT & 0x00ff;
284   UINT8 inWin0Mask = m_WININ & 0x00ff;
285   UINT8 inWin1Mask = m_WININ >> 8;
286   UINT8 outMask = m_WINOUT & 0x00ff;
270287
271   if(state->m_DISPCNT & DISPCNT_WIN0_EN)
288   if(m_DISPCNT & DISPCNT_WIN0_EN)
272289   {
273      UINT8 v0 = state->m_WIN0V >> 8;
274      UINT8 v1 = state->m_WIN0V & 0x00ff;
290      UINT8 v0 = m_WIN0V >> 8;
291      UINT8 v1 = m_WIN0V & 0x00ff;
275292      inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
276293      if(v1 >= v0)
277294      {
r23152r23153
283300      }
284301   }
285302
286   if(state->m_DISPCNT & DISPCNT_WIN1_EN)
303   if(m_DISPCNT & DISPCNT_WIN1_EN)
287304   {
288      UINT8 v0 = state->m_WIN1V >> 8;
289      UINT8 v1 = state->m_WIN1V & 0x00ff;
305      UINT8 v0 = m_WIN1V >> 8;
306      UINT8 v1 = m_WIN1V & 0x00ff;
290307      inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
291308      if(v1 >= v0)
292309      {
r23152r23153
298315      }
299316   }
300317
301   draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS);
302   draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS);
303   draw_roz_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed);
304   draw_gba_oam(state, machine, lineOBJ, y);
305   draw_gba_oam_window(state, machine, lineOBJWin, y);
318   draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
319   draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
320   draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed);
321   draw_gba_oam(lineOBJ, y);
322   draw_gba_oam_window(lineOBJWin, y);
306323
307324   for(x = 0; x < 240; x++)
308325   {
r23152r23153
312329
313330      if((lineOBJWin[x] & 0x80000000) == 0)
314331      {
315         mask = state->m_WINOUT >> 8;
332         mask = m_WINOUT >> 8;
316333      }
317334
318335      if(inWindow1)
319336      {
320         if(is_in_window(state, x, 1))
337         if(is_in_window(x, 1))
321338         {
322339            mask = inWin1Mask;
323340         }
r23152r23153
325342
326343      if(inWindow0)
327344      {
328         if(is_in_window(state, x, 0))
345         if(is_in_window(x, 0))
329346         {
330347            mask = inWin0Mask;
331348         }
r23152r23153
359376      {
360377         if((color & 0x00010000) == 0)
361378         {
362            switch(state->m_BLDCNT & BLDCNT_SFX)
379            switch(m_BLDCNT & BLDCNT_SFX)
363380            {
364381               case BLDCNT_SFX_NONE:
365382                  break;
366383               case BLDCNT_SFX_ALPHA:
367384               {
368                  if(top & state->m_BLDCNT)
385                  if(top & m_BLDCNT)
369386                  {
370387                     UINT32 back = backdrop;
371388                     UINT8 top2 = 0x20;
r23152r23153
405422                        }
406423                     }
407424
408                     if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
425                     if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
409426                     {
410                        color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
427                        color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
411428                     }
412429                  }
413430                  break;
414431               }
415432               case BLDCNT_SFX_LIGHTEN:
416                  if(top & state->m_BLDCNT)
433                  if(top & m_BLDCNT)
417434                  {
418                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
435                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
419436                  }
420437                  break;
421438               case BLDCNT_SFX_DARKEN:
422                  if(top & state->m_BLDCNT)
439                  if(top & m_BLDCNT)
423440                  {
424                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
441                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
425442                  }
426443                  break;
427444            }
r23152r23153
449466               top2 = 0x04;
450467            }
451468
452            if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
469            if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
453470            {
454               color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
471               color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
455472            }
456473            else
457474            {
458               switch(state->m_BLDCNT & BLDCNT_SFX)
475               switch(m_BLDCNT & BLDCNT_SFX)
459476               {
460477                  case BLDCNT_SFX_LIGHTEN:
461                     if(top & state->m_BLDCNT)
478                     if(top & m_BLDCNT)
462479                     {
463                        color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
480                        color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
464481                     }
465482                     break;
466483                  case BLDCNT_SFX_DARKEN:
467                     if(top & state->m_BLDCNT)
484                     if(top & m_BLDCNT)
468485                     {
469                        color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
486                        color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
470487                     }
471488                     break;
472489               }
r23152r23153
496513            top2 = 0x04;
497514         }
498515
499         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
516         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
500517         {
501            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
518            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
502519         }
503520         else
504521         {
505            switch(state->m_BLDCNT & BLDCNT_SFX)
522            switch(m_BLDCNT & BLDCNT_SFX)
506523            {
507524               case BLDCNT_SFX_LIGHTEN:
508                  if(top & state->m_BLDCNT)
525                  if(top & m_BLDCNT)
509526                  {
510                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
527                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
511528                  }
512529                  break;
513530               case BLDCNT_SFX_DARKEN:
514                  if(top & state->m_BLDCNT)
531                  if(top & m_BLDCNT)
515532                  {
516                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
533                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
517534                  }
518535                  break;
519536            }
r23152r23153
521538      }
522539      lineMix[x] = color;
523540   }
524   state->m_gfxBG2Changed = 0;
541   m_gfxBG2Changed = 0;
525542}
trunk/src/mess/video/gbamode2.c
r23152r23153
1   /***************************************************************************
1/***************************************************************************
22
33   gbamode2.c
44
r23152r23153
88
99***************************************************************************/
1010
11static void draw_mode2_scanline(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
11
12void gba_state::draw_mode2(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
1213{
14   switch (submode)
15   {
16      case 0:
17         draw_mode2_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
18         break;
19      case 1:
20         draw_mode2_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
21         break;
22      case 2:
23         draw_mode2_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
24         break;
25   }
26}
27
28void gba_state::draw_mode2_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
29{
1330   int x = 0;
14   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
31   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
1532
16   draw_roz_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed);
17   draw_roz_scanline(state, line3, y, DISPCNT_BG3_EN, state->m_BG3CNT, state->m_BG3X, state->m_BG3Y, state->m_BG3PA, state->m_BG3PB, state->m_BG3PC, state->m_BG3PD, &state->m_gfxBG3X, &state->m_gfxBG3Y, state->m_gfxBG3Changed);
18   draw_gba_oam(state, machine, lineOBJ, y);
33   draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed);
34   draw_roz_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3X, m_BG3Y, m_BG3PA, m_BG3PB, m_BG3PC, m_BG3PD, &m_gfxBG3X, &m_gfxBG3Y, m_gfxBG3Changed);
35   draw_gba_oam(lineOBJ, y);
1936
2037   for(x = 0; x < 240; x++)
2138   {
r23152r23153
5774            top2 = 0x08;
5875         }
5976
60         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
77         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
6178         {
62            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
79            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
6380         }
6481         else
6582         {
66            switch(state->m_BLDCNT & BLDCNT_SFX)
83            switch(m_BLDCNT & BLDCNT_SFX)
6784            {
6885               case BLDCNT_SFX_LIGHTEN:
69                  if(top & state->m_BLDCNT)
86                  if(top & m_BLDCNT)
7087                  {
71                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
88                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
7289                  }
7390                  break;
7491               case BLDCNT_SFX_DARKEN:
75                  if(top & state->m_BLDCNT)
92                  if(top & m_BLDCNT)
7693                  {
77                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
94                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
7895                  }
7996                  break;
8097            }
r23152r23153
83100
84101      lineMix[x] = color;
85102   }
86   state->m_gfxBG2Changed = 0;
87   state->m_gfxBG3Changed = 0;
103   m_gfxBG2Changed = 0;
104   m_gfxBG3Changed = 0;
88105}
89106
90static void draw_mode2_scanline_nowindow(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
107void gba_state::draw_mode2_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
91108{
92109   int x = 0;
93   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
94   int effect = state->m_BLDCNT & BLDCNT_SFX;
110   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
111   int effect = m_BLDCNT & BLDCNT_SFX;
95112
96   draw_roz_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed);
97   draw_roz_scanline(state, line3, y, DISPCNT_BG3_EN, state->m_BG3CNT, state->m_BG3X, state->m_BG3Y, state->m_BG3PA, state->m_BG3PB, state->m_BG3PC, state->m_BG3PD, &state->m_gfxBG3X, &state->m_gfxBG3Y, state->m_gfxBG3Changed);
98   draw_gba_oam(state, machine, lineOBJ, y);
113   draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed);
114   draw_roz_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3X, m_BG3Y, m_BG3PA, m_BG3PB, m_BG3PC, m_BG3PD, &m_gfxBG3X, &m_gfxBG3Y, m_gfxBG3Changed);
115   draw_gba_oam(lineOBJ, y);
99116
100117   for(x = 0; x < 240; x++)
101118   {
r23152r23153
127144            case BLDCNT_SFX_NONE:
128145               break;
129146            case BLDCNT_SFX_ALPHA:
130               if(state->m_BLDCNT & top)
147               if(m_BLDCNT & top)
131148               {
132149                  UINT32 back = backdrop;
133150                  UINT8 top2 = 0x20;
r23152r23153
159176                     }
160177                  }
161178
162                  if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
179                  if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
163180                  {
164                     color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
181                     color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
165182                  }
166183               }
167184               break;
168185            case BLDCNT_SFX_LIGHTEN:
169               if(top & state->m_BLDCNT)
186               if(top & m_BLDCNT)
170187               {
171                  color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
188                  color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
172189               }
173190               break;
174191            case BLDCNT_SFX_DARKEN:
175               if(top & state->m_BLDCNT)
192               if(top & m_BLDCNT)
176193               {
177                  color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
194                  color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
178195               }
179196               break;
180197         }
r23152r23153
196213            top2 = 0x08;
197214         }
198215
199         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
216         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
200217         {
201            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
218            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
202219         }
203220         else
204221         {
205            switch(state->m_BLDCNT & BLDCNT_SFX)
222            switch(m_BLDCNT & BLDCNT_SFX)
206223            {
207224               case BLDCNT_SFX_LIGHTEN:
208                  if(top & state->m_BLDCNT)
225                  if(top & m_BLDCNT)
209226                  {
210                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
227                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
211228                  }
212229                  break;
213230               case BLDCNT_SFX_DARKEN:
214                  if(top & state->m_BLDCNT)
231                  if(top & m_BLDCNT)
215232                  {
216                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
233                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
217234                  }
218235                  break;
219236            }
r23152r23153
221238      }
222239      lineMix[x] = color;
223240   }
224   state->m_gfxBG2Changed = 0;
225   state->m_gfxBG3Changed = 0;
241   m_gfxBG2Changed = 0;
242   m_gfxBG3Changed = 0;
226243}
227244
228static void draw_mode2_scanline_all(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
245void gba_state::draw_mode2_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
229246{
230247   int x = 0;
231   UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000;
248   UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
232249   int inWindow0 = 0;
233250   int inWindow1 = 0;
234   UINT8 inWin0Mask = state->m_WININ & 0x00ff;
235   UINT8 inWin1Mask = state->m_WININ >> 8;
236   UINT8 outMask = state->m_WINOUT & 0x00ff;
251   UINT8 inWin0Mask = m_WININ & 0x00ff;
252   UINT8 inWin1Mask = m_WININ >> 8;
253   UINT8 outMask = m_WINOUT & 0x00ff;
237254
238   if(state->m_DISPCNT & DISPCNT_WIN0_EN)
255   if(m_DISPCNT & DISPCNT_WIN0_EN)
239256   {
240      UINT8 v0 = state->m_WIN0V >> 8;
241      UINT8 v1 = state->m_WIN0V & 0x00ff;
257      UINT8 v0 = m_WIN0V >> 8;
258      UINT8 v1 = m_WIN0V & 0x00ff;
242259      inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
243260      if(v1 >= v0)
244261      {
r23152r23153
250267      }
251268   }
252269
253   if(state->m_DISPCNT & DISPCNT_WIN1_EN)
270   if(m_DISPCNT & DISPCNT_WIN1_EN)
254271   {
255      UINT8 v0 = state->m_WIN1V >> 8;
256      UINT8 v1 = state->m_WIN1V & 0x00ff;
272      UINT8 v0 = m_WIN1V >> 8;
273      UINT8 v1 = m_WIN1V & 0x00ff;
257274      inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
258275      if(v1 >= v0)
259276      {
r23152r23153
265282      }
266283   }
267284
268   draw_roz_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed);
269   draw_roz_scanline(state, line3, y, DISPCNT_BG3_EN, state->m_BG3CNT, state->m_BG3X, state->m_BG3Y, state->m_BG3PA, state->m_BG3PB, state->m_BG3PC, state->m_BG3PD, &state->m_gfxBG3X, &state->m_gfxBG3Y, state->m_gfxBG3Changed);
270   draw_gba_oam(state, machine, lineOBJ, y);
271   draw_gba_oam_window(state, machine, lineOBJWin, y);
285   draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed);
286   draw_roz_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3X, m_BG3Y, m_BG3PA, m_BG3PB, m_BG3PC, m_BG3PD, &m_gfxBG3X, &m_gfxBG3Y, m_gfxBG3Changed);
287   draw_gba_oam(lineOBJ, y);
288   draw_gba_oam_window(lineOBJWin, y);
272289
273290   for(x = 0; x < 240; x++)
274291   {
r23152r23153
278295
279296      if((lineOBJWin[x] & 0x80000000) == 0)
280297      {
281         mask = state->m_WINOUT >> 8;
298         mask = m_WINOUT >> 8;
282299      }
283300
284301      if(inWindow1)
285302      {
286         if(is_in_window(state, x, 1))
303         if(is_in_window(x, 1))
287304         {
288305            mask = inWin1Mask;
289306         }
r23152r23153
291308
292309      if(inWindow0)
293310      {
294         if(is_in_window(state, x, 0))
311         if(is_in_window(x, 0))
295312         {
296313            mask = inWin0Mask;
297314         }
r23152r23153
319336      {
320337         if((color & 0x00010000) == 0)
321338         {
322            switch(state->m_BLDCNT & BLDCNT_SFX)
339            switch(m_BLDCNT & BLDCNT_SFX)
323340            {
324341               case BLDCNT_SFX_NONE:
325342                  break;
326343               case BLDCNT_SFX_ALPHA:
327344               {
328                  if(top & state->m_BLDCNT)
345                  if(top & m_BLDCNT)
329346                  {
330347                     UINT32 back = backdrop;
331348                     UINT8 top2 = 0x20;
r23152r23153
356373                        }
357374                     }
358375
359                     if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
376                     if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
360377                     {
361                        color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
378                        color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
362379                     }
363380                  }
364381                  break;
365382               }
366383               case BLDCNT_SFX_LIGHTEN:
367                  if(top & state->m_BLDCNT)
384                  if(top & m_BLDCNT)
368385                  {
369                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
386                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
370387                  }
371388                  break;
372389               case BLDCNT_SFX_DARKEN:
373                  if(top & state->m_BLDCNT)
390                  if(top & m_BLDCNT)
374391                  {
375                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
392                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
376393                  }
377394                  break;
378395            }
r23152r23153
394411               top2 = 0x08;
395412            }
396413
397            if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
414            if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
398415            {
399               color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
416               color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
400417            }
401418            else
402419            {
403               switch(state->m_BLDCNT & BLDCNT_SFX)
420               switch(m_BLDCNT & BLDCNT_SFX)
404421               {
405422                  case BLDCNT_SFX_LIGHTEN:
406                     if(top & state->m_BLDCNT)
423                     if(top & m_BLDCNT)
407424                     {
408                        color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
425                        color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
409426                     }
410427                     break;
411428                  case BLDCNT_SFX_DARKEN:
412                     if(top & state->m_BLDCNT)
429                     if(top & m_BLDCNT)
413430                     {
414                        color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
431                        color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
415432                     }
416433                     break;
417434               }
r23152r23153
435452            top2 = 0x08;
436453         }
437454
438         if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
455         if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
439456         {
440            color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
457            color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
441458         }
442459         else
443460         {
444            switch(state->m_BLDCNT & BLDCNT_SFX)
461            switch(m_BLDCNT & BLDCNT_SFX)
445462            {
446463               case BLDCNT_SFX_LIGHTEN:
447                  if(top & state->m_BLDCNT)
464                  if(top & m_BLDCNT)
448465                  {
449                     color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
466                     color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
450467                  }
451468                  break;
452469               case BLDCNT_SFX_DARKEN:
453                  if(top & state->m_BLDCNT)
470                  if(top & m_BLDCNT)
454471                  {
455                     color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
472                     color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
456473                  }
457474                  break;
458475            }
r23152r23153
460477      }
461478      lineMix[x] = color;
462479   }
463   state->m_gfxBG2Changed = 0;
464   state->m_gfxBG3Changed = 0;
480   m_gfxBG2Changed = 0;
481   m_gfxBG3Changed = 0;
465482}
trunk/src/mess/video/gba.c
r23152r23153
3131   16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
3232};
3333
34/* Drawing functions */
35static void draw_roz_bitmap_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed, int depth);
36static void draw_roz_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed);
37static void draw_bg_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, UINT32 hofs, UINT32 vofs);
38static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT32 *scanline, int y);
39static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *scanline, int y);
40static void invalid_gba_draw_function(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int aux);
41
4234/* Utility functions */
43INLINE int is_in_window(gba_state *state, int x, int window);
4435INLINE UINT32 alpha_blend_pixel(UINT32 color0, UINT32 color1, int ca, int cb);
4536INLINE UINT32 increase_brightness(UINT32 color, int coeff_);
4637INLINE UINT32 decrease_brightness(UINT32 color, int coeff_);
r23152r23153
5041#include "gbamode2.c"
5142#include "gbam345.c"
5243
53static void (*const gba_draw_scanline_modes[8][3])(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int aux) =
54{
55   /* All modes have three sub-modes: No effects, effects, and windowed effects. */
56   {   /* Mode 0: 4 non-rotatable tilemaps and 1 OAM layer */
57      &draw_mode0_scanline,
58      &draw_mode0_scanline_nowindow,
59      &draw_mode0_scanline_all
60   },
61   {   /* Mode 1: 2 non-rotatable tilemaps, 1 rotozoomable tilemap, and 1 OAM layer */
62      &draw_mode1_scanline,
63      &draw_mode1_scanline_nowindow,
64      &draw_mode1_scanline_all
65   },
66   {   /* Mode 2: 2 rotozoomable tilemaps, and 1 OAM layer */
67      &draw_mode2_scanline,
68      &draw_mode2_scanline_nowindow,
69      &draw_mode2_scanline_all
70   },
71   {   /* Mode 3: 1 rotatable 8bpp bitmap and one OAM layer */
72      &draw_roz_bitmap_mode_scanline,
73      &draw_roz_bitmap_mode_scanline_nowindow,
74      &draw_roz_bitmap_mode_scanline_all
75   },
76   {   /* Mode 4: 1 rotatable 16bpp bitmap and one OAM layer */
77      &draw_roz_bitmap_mode_scanline,
78      &draw_roz_bitmap_mode_scanline_nowindow,
79      &draw_roz_bitmap_mode_scanline_all
80   },
81   {   /* Mode 5: 1 rotatable 4bpp bitmap and one OAM layer */
82      &draw_roz_bitmap_mode_scanline,
83      &draw_roz_bitmap_mode_scanline_nowindow,
84      &draw_roz_bitmap_mode_scanline_all
85   },
86   {
87      &invalid_gba_draw_function,
88      &invalid_gba_draw_function,
89      &invalid_gba_draw_function,
90   },
91   {
92      &invalid_gba_draw_function,
93      &invalid_gba_draw_function,
94      &invalid_gba_draw_function,
95   },
96};
9744
98static void invalid_gba_draw_function(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int aux)
45void gba_state::draw_roz_bitmap_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed, int depth)
9946{
100   fatalerror( "Invalid screen mode (6 or 7)!\n" );
101}
102
103static void draw_roz_bitmap_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed, int depth)
104{
105   UINT8 *src8 = (UINT8 *)state->m_gba_vram.target();
106   UINT16 *src16 = (UINT16 *)state->m_gba_vram.target();
107   UINT16 *palette = (UINT16 *)state->m_gba_pram.target();
47   UINT8 *src8 = (UINT8 *)m_gba_vram.target();
48   UINT16 *src16 = (UINT16 *)m_gba_vram.target();
49   UINT16 *palette = (UINT16 *)m_gba_pram.target();
10850   INT32 sx = (depth == 4) ? 160 : 240;
10951   INT32 sy = (depth == 4) ? 128 : 160;
11052   UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000;
11153   INT32 dx, dmx, dy, dmy, startx, starty;
11254   INT32 rx, ry, pixx, pixy, x;
11355
114   if ((depth == 8) && (state->m_DISPCNT & DISPCNT_FRAMESEL))
56   if ((depth == 8) && (m_DISPCNT & DISPCNT_FRAMESEL))
11557      src8 += 0xa000;
11658
117   if ((depth == 4) && (state->m_DISPCNT & DISPCNT_FRAMESEL))
59   if ((depth == 4) && (m_DISPCNT & DISPCNT_FRAMESEL))
11860      src16 += 0xa000/2;
11961
12062   // sign extend roz parameters
r23152r23153
15193
15294   if(ctrl & BGCNT_MOSAIC)
15395   {
154      INT32 mosaic_line = ((state->m_MOSAIC & 0x00f0) >> 4) + 1;
96      INT32 mosaic_line = ((m_MOSAIC & 0x00f0) >> 4) + 1;
15597      INT32 tempy = (ypos / mosaic_line) * mosaic_line;
15698      rx = startx + tempy*dmx;
15799      ry = starty + tempy*dmy;
r23152r23153
188130
189131   if(ctrl & BGCNT_MOSAIC)
190132   {
191      INT32 mosaicx = (state->m_MOSAIC & 0x0f) + 1;
133      INT32 mosaicx = (m_MOSAIC & 0x0f) + 1;
192134      if(mosaicx > 1)
193135      {
194136         INT32 m = 1;
r23152r23153
206148   }
207149}
208150
209static void draw_roz_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed)
151void gba_state::draw_roz_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed)
210152{
211153   UINT32 base, mapbase, size;
212154   static const INT32 sizes[4] = { 128, 256, 512, 1024 };
213155   INT32 cx, cy, x, pixx, pixy;
214   UINT8 *mgba_vram = (UINT8 *)state->m_gba_vram.target();
156   UINT8 *mgba_vram = (UINT8 *)m_gba_vram.target();
215157   UINT32 tile;
216   UINT16 *pgba_pram = (UINT16 *)state->m_gba_pram.target();
158   UINT16 *pgba_pram = (UINT16 *)m_gba_pram.target();
217159   UINT16 pixel;
218160   UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000;
219161
r23152r23153
222164      scanline[x] = 0x80000000;
223165   }
224166
225   if (state->m_DISPCNT & enablemask)
167   if (m_DISPCNT & enablemask)
226168   {
227169      base = ((ctrl & BGCNT_CHARBASE) >> BGCNT_CHARBASE_SHIFT) * 0x4000;          // VRAM base of tiles
228170      mapbase = ((ctrl & BGCNT_SCREENBASE) >> BGCNT_SCREENBASE_SHIFT) * 0x800;    // VRAM base of map
r23152r23153
264206
265207      if(ctrl & BGCNT_MOSAIC)
266208      {
267         int mosaicy = ((state->m_MOSAIC & 0xf0) >> 4) + 1;
209         int mosaicy = ((m_MOSAIC & 0xf0) >> 4) + 1;
268210         int y = ypos % mosaicy;
269211         cx -= y*PB;
270212         cy -= y*PD;
r23152r23153
372314
373315      if(ctrl & BGCNT_MOSAIC)
374316      {
375         int mosaicx = (state->m_MOSAIC & 0x0f) + 1;
317         int mosaicx = (m_MOSAIC & 0x0f) + 1;
376318         if(mosaicx > 1)
377319         {
378320            int m = 1;
r23152r23153
391333   }
392334}
393335
394static void draw_bg_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, UINT32 hofs, UINT32 vofs)
336void gba_state::draw_bg_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, UINT32 hofs, UINT32 vofs)
395337{
396   UINT8 *vram = (UINT8*)state->m_gba_vram.target();
397   UINT16 *palette = (UINT16*)state->m_gba_pram.target();
338   UINT8 *vram = (UINT8*)m_gba_vram.target();
339   UINT16 *palette = (UINT16*)m_gba_pram.target();
398340   UINT8 *chardata = &vram[((ctrl & BGCNT_CHARBASE) >> BGCNT_CHARBASE_SHIFT) * 0x4000];
399341   UINT16 *screendata = (UINT16*)&vram[((ctrl & BGCNT_SCREENBASE) >> BGCNT_SCREENBASE_SHIFT) * 0x800];
400342   UINT32 priority = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000;
r23152r23153
402344   INT32 height = 256;
403345   INT32 maskx, masky, pixx, pixy;
404346   UINT8 use_mosaic = (ctrl & BGCNT_MOSAIC) ? 1 : 0;
405   INT32 mosaicx = (state->m_MOSAIC & 0x000f) + 1;
406   INT32 mosaicy = ((state->m_MOSAIC & 0x00f0) >> 4) + 1;
347   INT32 mosaicx = (m_MOSAIC & 0x000f) + 1;
348   INT32 mosaicy = ((m_MOSAIC & 0x00f0) >> 4) + 1;
407349   INT32 stride;
408350   INT32 x;
409351
410   if(!(state->m_DISPCNT & enablemask))
352   if(!(m_DISPCNT & enablemask))
411353   {
412354      for(x = 0; x < 240; x++)
413355      {
r23152r23153
615557   }
616558}
617559
618static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT32 *scanline, int y)
560void gba_state::draw_gba_oam_window(UINT32 *scanline, int y)
619561{
620562   INT16 gba_oamindex;
621563   UINT32 tilebytebase, tileindex, tiledrawindex;
622564   UINT32 width, height;
623   UINT16 *pgba_oam = (UINT16 *)state->m_gba_oam.target();
565   UINT16 *pgba_oam = (UINT16 *)m_gba_oam.target();
624566   int x = 0;
625   UINT8 *src = (UINT8*)state->m_gba_vram.target();
567   UINT8 *src = (UINT8*)m_gba_vram.target();
626568
627569   for(x = 0; x < 240; x++)
628570   {
629571      scanline[x] = 0x80000000;
630572   }
631573
632   if( state->m_DISPCNT & DISPCNT_OBJWIN_EN )
574   if( m_DISPCNT & DISPCNT_OBJWIN_EN )
633575   {
634576      for( gba_oamindex = 127; gba_oamindex >= 0; gba_oamindex-- )
635577      {
r23152r23153
725667               default:
726668                  width = 0;
727669                  height = 0;
728                  verboselog(machine, 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" );
670                  verboselog(machine(), 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" );
729671                  break;
730672            }
731673
r23152r23153
773715                     if((attr0 & OBJ_PALMODE) == OBJ_PALMODE_256)
774716                     {
775717                        int inc = 32;
776                        if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
718                        if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
777719                        {
778720                           continue;
779721                        }
780                        if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
722                        if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
781723                        {
782724                           inc = sx >> 2;
783725                        }
r23152r23153
812754                     else
813755                     {
814756                        int inc = 32;
815                        if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
757                        if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
816758                        {
817759                           continue;
818760                        }
819                        if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
761                        if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
820762                        {
821763                           inc = sx >> 3;
822764                        }
r23152r23153
876818                        {
877819                           cury_ = height - cury_ - 1;
878820                        }
879                        if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
821                        if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
880822                        {
881823                           continue;
882824                        }
883825
884                        if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
826                        if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
885827                        {
886828                           inc = width >> 2;
887829                        }
r23152r23153
955897                        {
956898                           cury_ = height - cury_ - 1;
957899                        }
958                        if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
900                        if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
959901                        {
960902                           continue;
961903                        }
962904
963                        if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
905                        if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
964906                        {
965907                           inc = width >> 3;
966908                        }
r23152r23153
10611003   }
10621004}
10631005
1064static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *scanline, int y)
1006void gba_state::draw_gba_oam(UINT32 *scanline, int y)
10651007{
10661008   INT16 gba_oamindex;
10671009   INT32 mosaiccnt = 0;
1068   INT32 mosaicy = ((state->m_MOSAIC & 0xf000) >> 12) + 1;
1069   INT32 mosaicx = ((state->m_MOSAIC & 0x0f00) >>  8) + 1;
1010   INT32 mosaicy = ((m_MOSAIC & 0xf000) >> 12) + 1;
1011   INT32 mosaicx = ((m_MOSAIC & 0x0f00) >>  8) + 1;
10701012   UINT32 tileindex, tiledrawindex; //, tilebytebase
10711013   UINT8 width, height;
1072   UINT16 *pgba_oam = (UINT16 *)state->m_gba_oam.target();
1073   UINT8 *src = (UINT8 *)state->m_gba_vram.target();
1074   UINT16 *palette = (UINT16*)state->m_gba_pram.target();
1014   UINT16 *pgba_oam = (UINT16 *)m_gba_oam.target();
1015   UINT8 *src = (UINT8 *)m_gba_vram.target();
1016   UINT16 *palette = (UINT16*)m_gba_pram.target();
10751017   int x = 0;
10761018
10771019   for(x = 0; x < 240; x++)
r23152r23153
10791021      scanline[x] = 0x80000000;
10801022   }
10811023
1082   if( state->m_DISPCNT & DISPCNT_OBJ_EN )
1024   if( m_DISPCNT & DISPCNT_OBJ_EN )
10831025   {
10841026      for( gba_oamindex = 0; gba_oamindex < 128; gba_oamindex++ )
10851027      {
r23152r23153
11661108               default:
11671109                  width = 0;
11681110                  height = 0;
1169                  verboselog(machine, 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" );
1111                  verboselog(machine(), 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" );
11701112                  break;
11711113            }
11721114
r23152r23153
12291171                     {
12301172                        INT32 inc = 32;
12311173
1232                        if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
1174                        if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
12331175                        {
12341176                           continue;
12351177                        }
12361178
1237                        if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
1179                        if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
12381180                        {
12391181                           inc = width >> 2;
12401182                        }
r23152r23153
12901232                        INT32 inc = 32;
12911233                        INT32 palentry = (attr2 >> 8) & 0xf0;
12921234
1293                        if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
1235                        if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
12941236                        {
12951237                           continue;
12961238                        }
12971239
1298                        if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
1240                        if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
12991241                        {
13001242                           inc = width >> 3;
13011243                        }
r23152r23153
13941336                           cury = height - cury - 1;
13951337                        }
13961338
1397                        if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
1339                        if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
13981340                        {
13991341                           continue;
14001342                        }
14011343
1402                        if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
1344                        if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
14031345                        {
14041346                           inc = width >> 2;
14051347                        }
r23152r23153
15021444                           cury = height - cury - 1;
15031445                        }
15041446
1505                        if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
1447                        if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
15061448                        {
15071449                           continue;
15081450                        }
15091451
1510                        if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
1452                        if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
15111453                        {
15121454                           inc = width >> 3;
15131455                        }
r23152r23153
16541596   }
16551597}
16561598
1657INLINE int is_in_window(gba_state *state, int x, int window)
1599inline int gba_state::is_in_window(int x, int window)
16581600{
1659   int x0 = state->m_WIN0H >> 8;
1660   int x1 = state->m_WIN0H & 0x00ff;
1601   int x0 = m_WIN0H >> 8;
1602   int x1 = m_WIN0H & 0x00ff;
16611603
16621604   if(window == 1)
16631605   {
1664      x0 = state->m_WIN1H >> 8;
1665      x1 = state->m_WIN1H & 0x00ff;
1606      x0 = m_WIN1H >> 8;
1607      x1 = m_WIN1H & 0x00ff;
16661608   }
16671609
16681610   if(x0 <= x1)
r23152r23153
17401682   return (color & 0xffff0000) | (b << 10) | (g << 5) | r;
17411683}
17421684
1743void gba_draw_scanline(running_machine &machine, int y)
1685void gba_state::draw_scanline(int y)
17441686{
1745   gba_state *state = machine.driver_data<gba_state>();
1746   bitmap_ind16 &bitmap = state->m_bitmap;
1687   bitmap_ind16 &bitmap = m_bitmap;
17471688   UINT16 *scanline = &bitmap.pix16(y);
17481689   int i, x;
17491690   UINT8 submode = 0;
1750   int bpp = 0;
17511691
17521692   // forced blank
1753   if (state->m_DISPCNT & DISPCNT_BLANK)
1693   if (m_DISPCNT & DISPCNT_BLANK)
17541694   {
17551695      // forced blank is white
17561696      for (i = 0; i < 240; i++)
r23152r23153
17601700      return;
17611701   }
17621702
1763   if(!state->m_fxOn && !state->m_windowOn && !(state->m_DISPCNT & DISPCNT_OBJWIN_EN))
1703   if(!m_fxOn && !m_windowOn && !(m_DISPCNT & DISPCNT_OBJWIN_EN))
17641704   {
17651705      submode = 0;
17661706   }
1767   else if(state->m_fxOn && !state->m_windowOn && !(state->m_DISPCNT & DISPCNT_OBJWIN_EN))
1707   else if(m_fxOn && !m_windowOn && !(m_DISPCNT & DISPCNT_OBJWIN_EN))
17681708   {
17691709      submode = 1;
17701710   }
r23152r23153
17731713      submode = 2;
17741714   }
17751715
1776   //printf( "mode = %d, %d\n", state->m_DISPCNT & 7, submode );
1716   //printf( "mode = %d, %d\n", m_DISPCNT & 7, submode );
17771717
1778   switch(state->m_DISPCNT & 7)
1718   switch(m_DISPCNT & 7)
17791719   {
1720      case 0:
1721         draw_mode0(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], 0);
1722         break;
1723      case 1:
1724         draw_mode1(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], 0);
1725         break;
1726      case 2:
1727         draw_mode2(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], 0);
1728         break;
17801729      case 3:
1781         bpp = 16;
1730         draw_mode345(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], 16);
17821731         break;
17831732      case 4:
1784         bpp = 8;
1733         draw_mode345(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], 8);
17851734         break;
17861735      case 5:
1787         bpp = 4;
1736         draw_mode345(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], 4);
17881737         break;
1738      default:
1739         fatalerror( "Invalid screen mode (6 or 7)!\n" );
1740         break;
17891741   }
17901742
1791   gba_draw_scanline_modes[state->m_DISPCNT & 7][submode](machine, state, y, &state->m_xferscan[0][1024], &state->m_xferscan[1][1024], &state->m_xferscan[2][1024], &state->m_xferscan[3][1024], &state->m_xferscan[4][1024], &state->m_xferscan[5][1024], &state->m_xferscan[6][1024], bpp);
1792
17931743   for(x = 0; x < 240; x++)
17941744   {
1795      scanline[x] = state->m_xferscan[6][1024 + x] & 0x7fff;
1745      scanline[x] = m_xferscan[6][1024 + x] & 0x7fff;
17961746   }
17971747
17981748   return;
trunk/src/mess/includes/gba.h
r23152r23153
33
44#include "audio/gb.h"
55#include "machine/intelfsh.h"
6#include "machine/gba_slot.h"
67#include "sound/dac.h"
7#include "machine/gba_slot.h"
88
99#define DISPSTAT_VBL            0x0001
1010#define DISPSTAT_HBL            0x0002
r23152r23153
252252   TIMER_CALLBACK_MEMBER(perform_hbl);
253253   TIMER_CALLBACK_MEMBER(perform_scan);
254254
255   // video related
256   void draw_scanline(int y);
257
258   void draw_roz_bitmap_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed, int depth);
259   void draw_roz_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed);
260   void draw_bg_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, UINT32 hofs, UINT32 vofs);
261   void draw_gba_oam_window(UINT32 *scanline, int y);
262   void draw_gba_oam(UINT32 *scanline, int y);
263
264   inline int is_in_window(int x, int window);
265   
266   void draw_mode0(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
267   void draw_mode1(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
268   void draw_mode2(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
269   void draw_mode345(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
270   
271   void draw_mode0_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
272   void draw_mode0_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
273   void draw_mode0_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
274   void draw_mode1_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
275   void draw_mode1_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
276   void draw_mode1_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
277   void draw_mode2_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
278   void draw_mode2_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
279   void draw_mode2_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
280   void draw_roz_bitmap_mode_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
281   void draw_roz_bitmap_mode_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
282   void draw_roz_bitmap_mode_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
283   
255284protected:
256285   required_memory_region m_region_maincpu;
257286   required_ioport m_io_in0;
258287};
259288
260/*----------- defined in video/gba.c -----------*/
261289
262void gba_draw_scanline(running_machine &machine, int y);
263
264290#endif

Previous 199869 Revisions Next


© 1997-2024 The MAME Team