(MESS) gba: modernized the video (i.e. moved variables inside the state class). nw.

This commit is contained in:
Fabio Priuli 2013-05-25 13:54:08 +00:00
parent 5ff188bd69
commit 1f771f514c
7 changed files with 486 additions and 443 deletions

View File

@ -18,7 +18,6 @@
#include "cpu/arm7/arm7.h" #include "cpu/arm7/arm7.h"
#include "cpu/arm7/arm7core.h" #include "cpu/arm7/arm7core.h"
#include "sound/dac.h" #include "sound/dac.h"
#include "machine/intelfsh.h"
#include "audio/gb.h" #include "audio/gb.h"
#include "includes/gba.h" #include "includes/gba.h"
#include "machine/gba_rom.h" #include "machine/gba_rom.h"
@ -1951,7 +1950,7 @@ TIMER_CALLBACK_MEMBER(gba_state::perform_hbl)
// draw only visible scanlines // draw only visible scanlines
if (scanline < 160) if (scanline < 160)
{ {
gba_draw_scanline(machine(), scanline); draw_scanline(scanline);
} }
m_DISPSTAT |= DISPSTAT_HBL; m_DISPSTAT |= DISPSTAT_HBL;
if ((m_DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0) if ((m_DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0)

View File

@ -3,8 +3,8 @@
#include "audio/gb.h" #include "audio/gb.h"
#include "machine/intelfsh.h" #include "machine/intelfsh.h"
#include "sound/dac.h"
#include "machine/gba_slot.h" #include "machine/gba_slot.h"
#include "sound/dac.h"
#define DISPSTAT_VBL 0x0001 #define DISPSTAT_VBL 0x0001
#define DISPSTAT_HBL 0x0002 #define DISPSTAT_HBL 0x0002
@ -252,13 +252,39 @@ public:
TIMER_CALLBACK_MEMBER(perform_hbl); TIMER_CALLBACK_MEMBER(perform_hbl);
TIMER_CALLBACK_MEMBER(perform_scan); TIMER_CALLBACK_MEMBER(perform_scan);
// video related
void draw_scanline(int y);
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);
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);
void draw_bg_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, UINT32 hofs, UINT32 vofs);
void draw_gba_oam_window(UINT32 *scanline, int y);
void draw_gba_oam(UINT32 *scanline, int y);
inline int is_in_window(int x, int window);
void draw_mode0(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode1(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode2(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode345(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode0_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode0_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode0_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode1_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode1_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode1_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode2_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode2_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_mode2_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
void draw_roz_bitmap_mode_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp);
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);
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);
protected: protected:
required_memory_region m_region_maincpu; required_memory_region m_region_maincpu;
required_ioport m_io_in0; required_ioport m_io_in0;
}; };
/*----------- defined in video/gba.c -----------*/
void gba_draw_scanline(running_machine &machine, int y);
#endif #endif

View File

@ -31,16 +31,7 @@ static const int coeff[32] = {
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
}; };
/* Drawing functions */
static 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);
static 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);
static void draw_bg_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, UINT32 hofs, UINT32 vofs);
static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT32 *scanline, int y);
static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *scanline, int y);
static 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);
/* Utility functions */ /* Utility functions */
INLINE int is_in_window(gba_state *state, int x, int window);
INLINE UINT32 alpha_blend_pixel(UINT32 color0, UINT32 color1, int ca, int cb); INLINE UINT32 alpha_blend_pixel(UINT32 color0, UINT32 color1, int ca, int cb);
INLINE UINT32 increase_brightness(UINT32 color, int coeff_); INLINE UINT32 increase_brightness(UINT32 color, int coeff_);
INLINE UINT32 decrease_brightness(UINT32 color, int coeff_); INLINE UINT32 decrease_brightness(UINT32 color, int coeff_);
@ -50,71 +41,22 @@ INLINE UINT32 decrease_brightness(UINT32 color, int coeff_);
#include "gbamode2.c" #include "gbamode2.c"
#include "gbam345.c" #include "gbam345.c"
static 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) =
{
/* All modes have three sub-modes: No effects, effects, and windowed effects. */
{ /* Mode 0: 4 non-rotatable tilemaps and 1 OAM layer */
&draw_mode0_scanline,
&draw_mode0_scanline_nowindow,
&draw_mode0_scanline_all
},
{ /* Mode 1: 2 non-rotatable tilemaps, 1 rotozoomable tilemap, and 1 OAM layer */
&draw_mode1_scanline,
&draw_mode1_scanline_nowindow,
&draw_mode1_scanline_all
},
{ /* Mode 2: 2 rotozoomable tilemaps, and 1 OAM layer */
&draw_mode2_scanline,
&draw_mode2_scanline_nowindow,
&draw_mode2_scanline_all
},
{ /* Mode 3: 1 rotatable 8bpp bitmap and one OAM layer */
&draw_roz_bitmap_mode_scanline,
&draw_roz_bitmap_mode_scanline_nowindow,
&draw_roz_bitmap_mode_scanline_all
},
{ /* Mode 4: 1 rotatable 16bpp bitmap and one OAM layer */
&draw_roz_bitmap_mode_scanline,
&draw_roz_bitmap_mode_scanline_nowindow,
&draw_roz_bitmap_mode_scanline_all
},
{ /* Mode 5: 1 rotatable 4bpp bitmap and one OAM layer */
&draw_roz_bitmap_mode_scanline,
&draw_roz_bitmap_mode_scanline_nowindow,
&draw_roz_bitmap_mode_scanline_all
},
{
&invalid_gba_draw_function,
&invalid_gba_draw_function,
&invalid_gba_draw_function,
},
{
&invalid_gba_draw_function,
&invalid_gba_draw_function,
&invalid_gba_draw_function,
},
};
static 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) void 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)
{ {
fatalerror( "Invalid screen mode (6 or 7)!\n" ); UINT8 *src8 = (UINT8 *)m_gba_vram.target();
} UINT16 *src16 = (UINT16 *)m_gba_vram.target();
UINT16 *palette = (UINT16 *)m_gba_pram.target();
static 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)
{
UINT8 *src8 = (UINT8 *)state->m_gba_vram.target();
UINT16 *src16 = (UINT16 *)state->m_gba_vram.target();
UINT16 *palette = (UINT16 *)state->m_gba_pram.target();
INT32 sx = (depth == 4) ? 160 : 240; INT32 sx = (depth == 4) ? 160 : 240;
INT32 sy = (depth == 4) ? 128 : 160; INT32 sy = (depth == 4) ? 128 : 160;
UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000; UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000;
INT32 dx, dmx, dy, dmy, startx, starty; INT32 dx, dmx, dy, dmy, startx, starty;
INT32 rx, ry, pixx, pixy, x; INT32 rx, ry, pixx, pixy, x;
if ((depth == 8) && (state->m_DISPCNT & DISPCNT_FRAMESEL)) if ((depth == 8) && (m_DISPCNT & DISPCNT_FRAMESEL))
src8 += 0xa000; src8 += 0xa000;
if ((depth == 4) && (state->m_DISPCNT & DISPCNT_FRAMESEL)) if ((depth == 4) && (m_DISPCNT & DISPCNT_FRAMESEL))
src16 += 0xa000/2; src16 += 0xa000/2;
// sign extend roz parameters // sign extend roz parameters
@ -151,7 +93,7 @@ static void draw_roz_bitmap_scanline(gba_state *state, UINT32 *scanline, int ypo
if(ctrl & BGCNT_MOSAIC) if(ctrl & BGCNT_MOSAIC)
{ {
INT32 mosaic_line = ((state->m_MOSAIC & 0x00f0) >> 4) + 1; INT32 mosaic_line = ((m_MOSAIC & 0x00f0) >> 4) + 1;
INT32 tempy = (ypos / mosaic_line) * mosaic_line; INT32 tempy = (ypos / mosaic_line) * mosaic_line;
rx = startx + tempy*dmx; rx = startx + tempy*dmx;
ry = starty + tempy*dmy; ry = starty + tempy*dmy;
@ -188,7 +130,7 @@ static void draw_roz_bitmap_scanline(gba_state *state, UINT32 *scanline, int ypo
if(ctrl & BGCNT_MOSAIC) if(ctrl & BGCNT_MOSAIC)
{ {
INT32 mosaicx = (state->m_MOSAIC & 0x0f) + 1; INT32 mosaicx = (m_MOSAIC & 0x0f) + 1;
if(mosaicx > 1) if(mosaicx > 1)
{ {
INT32 m = 1; INT32 m = 1;
@ -206,14 +148,14 @@ static void draw_roz_bitmap_scanline(gba_state *state, UINT32 *scanline, int ypo
} }
} }
static 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) void 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)
{ {
UINT32 base, mapbase, size; UINT32 base, mapbase, size;
static const INT32 sizes[4] = { 128, 256, 512, 1024 }; static const INT32 sizes[4] = { 128, 256, 512, 1024 };
INT32 cx, cy, x, pixx, pixy; INT32 cx, cy, x, pixx, pixy;
UINT8 *mgba_vram = (UINT8 *)state->m_gba_vram.target(); UINT8 *mgba_vram = (UINT8 *)m_gba_vram.target();
UINT32 tile; UINT32 tile;
UINT16 *pgba_pram = (UINT16 *)state->m_gba_pram.target(); UINT16 *pgba_pram = (UINT16 *)m_gba_pram.target();
UINT16 pixel; UINT16 pixel;
UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000; UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000;
@ -222,7 +164,7 @@ static void draw_roz_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT
scanline[x] = 0x80000000; scanline[x] = 0x80000000;
} }
if (state->m_DISPCNT & enablemask) if (m_DISPCNT & enablemask)
{ {
base = ((ctrl & BGCNT_CHARBASE) >> BGCNT_CHARBASE_SHIFT) * 0x4000; // VRAM base of tiles base = ((ctrl & BGCNT_CHARBASE) >> BGCNT_CHARBASE_SHIFT) * 0x4000; // VRAM base of tiles
mapbase = ((ctrl & BGCNT_SCREENBASE) >> BGCNT_SCREENBASE_SHIFT) * 0x800; // VRAM base of map mapbase = ((ctrl & BGCNT_SCREENBASE) >> BGCNT_SCREENBASE_SHIFT) * 0x800; // VRAM base of map
@ -264,7 +206,7 @@ static void draw_roz_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT
if(ctrl & BGCNT_MOSAIC) if(ctrl & BGCNT_MOSAIC)
{ {
int mosaicy = ((state->m_MOSAIC & 0xf0) >> 4) + 1; int mosaicy = ((m_MOSAIC & 0xf0) >> 4) + 1;
int y = ypos % mosaicy; int y = ypos % mosaicy;
cx -= y*PB; cx -= y*PB;
cy -= y*PD; cy -= y*PD;
@ -372,7 +314,7 @@ static void draw_roz_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT
if(ctrl & BGCNT_MOSAIC) if(ctrl & BGCNT_MOSAIC)
{ {
int mosaicx = (state->m_MOSAIC & 0x0f) + 1; int mosaicx = (m_MOSAIC & 0x0f) + 1;
if(mosaicx > 1) if(mosaicx > 1)
{ {
int m = 1; int m = 1;
@ -391,10 +333,10 @@ static void draw_roz_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT
} }
} }
static void draw_bg_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, UINT32 hofs, UINT32 vofs) void gba_state::draw_bg_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, UINT32 hofs, UINT32 vofs)
{ {
UINT8 *vram = (UINT8*)state->m_gba_vram.target(); UINT8 *vram = (UINT8*)m_gba_vram.target();
UINT16 *palette = (UINT16*)state->m_gba_pram.target(); UINT16 *palette = (UINT16*)m_gba_pram.target();
UINT8 *chardata = &vram[((ctrl & BGCNT_CHARBASE) >> BGCNT_CHARBASE_SHIFT) * 0x4000]; UINT8 *chardata = &vram[((ctrl & BGCNT_CHARBASE) >> BGCNT_CHARBASE_SHIFT) * 0x4000];
UINT16 *screendata = (UINT16*)&vram[((ctrl & BGCNT_SCREENBASE) >> BGCNT_SCREENBASE_SHIFT) * 0x800]; UINT16 *screendata = (UINT16*)&vram[((ctrl & BGCNT_SCREENBASE) >> BGCNT_SCREENBASE_SHIFT) * 0x800];
UINT32 priority = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000; UINT32 priority = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000;
@ -402,12 +344,12 @@ static void draw_bg_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT3
INT32 height = 256; INT32 height = 256;
INT32 maskx, masky, pixx, pixy; INT32 maskx, masky, pixx, pixy;
UINT8 use_mosaic = (ctrl & BGCNT_MOSAIC) ? 1 : 0; UINT8 use_mosaic = (ctrl & BGCNT_MOSAIC) ? 1 : 0;
INT32 mosaicx = (state->m_MOSAIC & 0x000f) + 1; INT32 mosaicx = (m_MOSAIC & 0x000f) + 1;
INT32 mosaicy = ((state->m_MOSAIC & 0x00f0) >> 4) + 1; INT32 mosaicy = ((m_MOSAIC & 0x00f0) >> 4) + 1;
INT32 stride; INT32 stride;
INT32 x; INT32 x;
if(!(state->m_DISPCNT & enablemask)) if(!(m_DISPCNT & enablemask))
{ {
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -615,21 +557,21 @@ static void draw_bg_scanline(gba_state *state, UINT32 *scanline, int ypos, UINT3
} }
} }
static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT32 *scanline, int y) void gba_state::draw_gba_oam_window(UINT32 *scanline, int y)
{ {
INT16 gba_oamindex; INT16 gba_oamindex;
UINT32 tilebytebase, tileindex, tiledrawindex; UINT32 tilebytebase, tileindex, tiledrawindex;
UINT32 width, height; UINT32 width, height;
UINT16 *pgba_oam = (UINT16 *)state->m_gba_oam.target(); UINT16 *pgba_oam = (UINT16 *)m_gba_oam.target();
int x = 0; int x = 0;
UINT8 *src = (UINT8*)state->m_gba_vram.target(); UINT8 *src = (UINT8*)m_gba_vram.target();
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
scanline[x] = 0x80000000; scanline[x] = 0x80000000;
} }
if( state->m_DISPCNT & DISPCNT_OBJWIN_EN ) if( m_DISPCNT & DISPCNT_OBJWIN_EN )
{ {
for( gba_oamindex = 127; gba_oamindex >= 0; gba_oamindex-- ) for( gba_oamindex = 127; gba_oamindex >= 0; gba_oamindex-- )
{ {
@ -725,7 +667,7 @@ static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT
default: default:
width = 0; width = 0;
height = 0; height = 0;
verboselog(machine, 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" ); verboselog(machine(), 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" );
break; break;
} }
@ -773,11 +715,11 @@ static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT
if((attr0 & OBJ_PALMODE) == OBJ_PALMODE_256) if((attr0 & OBJ_PALMODE) == OBJ_PALMODE_256)
{ {
int inc = 32; int inc = 32;
if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
{ {
continue; continue;
} }
if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
{ {
inc = sx >> 2; inc = sx >> 2;
} }
@ -812,11 +754,11 @@ static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT
else else
{ {
int inc = 32; int inc = 32;
if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
{ {
continue; continue;
} }
if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
{ {
inc = sx >> 3; inc = sx >> 3;
} }
@ -876,12 +818,12 @@ static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT
{ {
cury_ = height - cury_ - 1; cury_ = height - cury_ - 1;
} }
if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
{ {
continue; continue;
} }
if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
{ {
inc = width >> 2; inc = width >> 2;
} }
@ -955,12 +897,12 @@ static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT
{ {
cury_ = height - cury_ - 1; cury_ = height - cury_ - 1;
} }
if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
{ {
continue; continue;
} }
if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
{ {
inc = width >> 3; inc = width >> 3;
} }
@ -1061,17 +1003,17 @@ static void draw_gba_oam_window(gba_state *state, running_machine &machine, UINT
} }
} }
static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *scanline, int y) void gba_state::draw_gba_oam(UINT32 *scanline, int y)
{ {
INT16 gba_oamindex; INT16 gba_oamindex;
INT32 mosaiccnt = 0; INT32 mosaiccnt = 0;
INT32 mosaicy = ((state->m_MOSAIC & 0xf000) >> 12) + 1; INT32 mosaicy = ((m_MOSAIC & 0xf000) >> 12) + 1;
INT32 mosaicx = ((state->m_MOSAIC & 0x0f00) >> 8) + 1; INT32 mosaicx = ((m_MOSAIC & 0x0f00) >> 8) + 1;
UINT32 tileindex, tiledrawindex; //, tilebytebase UINT32 tileindex, tiledrawindex; //, tilebytebase
UINT8 width, height; UINT8 width, height;
UINT16 *pgba_oam = (UINT16 *)state->m_gba_oam.target(); UINT16 *pgba_oam = (UINT16 *)m_gba_oam.target();
UINT8 *src = (UINT8 *)state->m_gba_vram.target(); UINT8 *src = (UINT8 *)m_gba_vram.target();
UINT16 *palette = (UINT16*)state->m_gba_pram.target(); UINT16 *palette = (UINT16*)m_gba_pram.target();
int x = 0; int x = 0;
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
@ -1079,7 +1021,7 @@ static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *sca
scanline[x] = 0x80000000; scanline[x] = 0x80000000;
} }
if( state->m_DISPCNT & DISPCNT_OBJ_EN ) if( m_DISPCNT & DISPCNT_OBJ_EN )
{ {
for( gba_oamindex = 0; gba_oamindex < 128; gba_oamindex++ ) for( gba_oamindex = 0; gba_oamindex < 128; gba_oamindex++ )
{ {
@ -1166,7 +1108,7 @@ static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *sca
default: default:
width = 0; width = 0;
height = 0; height = 0;
verboselog(machine, 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" ); verboselog(machine(), 0, "OAM error: Trying to draw OBJ with OBJ_SHAPE = 3!\n" );
break; break;
} }
@ -1229,12 +1171,12 @@ static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *sca
{ {
INT32 inc = 32; INT32 inc = 32;
if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
{ {
continue; continue;
} }
if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
{ {
inc = width >> 2; inc = width >> 2;
} }
@ -1290,12 +1232,12 @@ static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *sca
INT32 inc = 32; INT32 inc = 32;
INT32 palentry = (attr2 >> 8) & 0xf0; INT32 palentry = (attr2 >> 8) & 0xf0;
if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
{ {
continue; continue;
} }
if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
{ {
inc = width >> 3; inc = width >> 3;
} }
@ -1394,12 +1336,12 @@ static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *sca
cury = height - cury - 1; cury = height - cury - 1;
} }
if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
{ {
continue; continue;
} }
if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
{ {
inc = width >> 2; inc = width >> 2;
} }
@ -1502,12 +1444,12 @@ static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *sca
cury = height - cury - 1; cury = height - cury - 1;
} }
if((state->m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200) if((m_DISPCNT & DISPCNT_MODE) > 2 && tiledrawindex < 0x200)
{ {
continue; continue;
} }
if((state->m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D) if((m_DISPCNT & DISPCNT_VRAM_MAP) == DISPCNT_VRAM_MAP_1D)
{ {
inc = width >> 3; inc = width >> 3;
} }
@ -1654,15 +1596,15 @@ static void draw_gba_oam(gba_state *state, running_machine &machine, UINT32 *sca
} }
} }
INLINE int is_in_window(gba_state *state, int x, int window) inline int gba_state::is_in_window(int x, int window)
{ {
int x0 = state->m_WIN0H >> 8; int x0 = m_WIN0H >> 8;
int x1 = state->m_WIN0H & 0x00ff; int x1 = m_WIN0H & 0x00ff;
if(window == 1) if(window == 1)
{ {
x0 = state->m_WIN1H >> 8; x0 = m_WIN1H >> 8;
x1 = state->m_WIN1H & 0x00ff; x1 = m_WIN1H & 0x00ff;
} }
if(x0 <= x1) if(x0 <= x1)
@ -1740,17 +1682,15 @@ INLINE UINT32 decrease_brightness(UINT32 color, int coeff_)
return (color & 0xffff0000) | (b << 10) | (g << 5) | r; return (color & 0xffff0000) | (b << 10) | (g << 5) | r;
} }
void gba_draw_scanline(running_machine &machine, int y) void gba_state::draw_scanline(int y)
{ {
gba_state *state = machine.driver_data<gba_state>(); bitmap_ind16 &bitmap = m_bitmap;
bitmap_ind16 &bitmap = state->m_bitmap;
UINT16 *scanline = &bitmap.pix16(y); UINT16 *scanline = &bitmap.pix16(y);
int i, x; int i, x;
UINT8 submode = 0; UINT8 submode = 0;
int bpp = 0;
// forced blank // forced blank
if (state->m_DISPCNT & DISPCNT_BLANK) if (m_DISPCNT & DISPCNT_BLANK)
{ {
// forced blank is white // forced blank is white
for (i = 0; i < 240; i++) for (i = 0; i < 240; i++)
@ -1760,11 +1700,11 @@ void gba_draw_scanline(running_machine &machine, int y)
return; return;
} }
if(!state->m_fxOn && !state->m_windowOn && !(state->m_DISPCNT & DISPCNT_OBJWIN_EN)) if(!m_fxOn && !m_windowOn && !(m_DISPCNT & DISPCNT_OBJWIN_EN))
{ {
submode = 0; submode = 0;
} }
else if(state->m_fxOn && !state->m_windowOn && !(state->m_DISPCNT & DISPCNT_OBJWIN_EN)) else if(m_fxOn && !m_windowOn && !(m_DISPCNT & DISPCNT_OBJWIN_EN))
{ {
submode = 1; submode = 1;
} }
@ -1773,26 +1713,36 @@ void gba_draw_scanline(running_machine &machine, int y)
submode = 2; submode = 2;
} }
//printf( "mode = %d, %d\n", state->m_DISPCNT & 7, submode ); //printf( "mode = %d, %d\n", m_DISPCNT & 7, submode );
switch(state->m_DISPCNT & 7) switch(m_DISPCNT & 7)
{ {
case 0:
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);
break;
case 1:
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);
break;
case 2:
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);
break;
case 3: case 3:
bpp = 16; 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);
break; break;
case 4: case 4:
bpp = 8; 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);
break; break;
case 5: case 5:
bpp = 4; 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);
break;
default:
fatalerror( "Invalid screen mode (6 or 7)!\n" );
break; break;
} }
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);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
scanline[x] = state->m_xferscan[6][1024 + x] & 0x7fff; scanline[x] = m_xferscan[6][1024 + x] & 0x7fff;
} }
return; return;

View File

@ -1,4 +1,4 @@
/*************************************************************************** /***************************************************************************
gbam345.c gbam345.c
@ -8,13 +8,30 @@
***************************************************************************/ ***************************************************************************/
static 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)
void gba_state::draw_mode345(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{
switch (submode)
{
case 0:
draw_roz_bitmap_mode_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
case 1:
draw_roz_bitmap_mode_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
case 2:
draw_roz_bitmap_mode_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
}
}
void 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)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
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); 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);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -44,24 +61,24 @@ static void draw_roz_bitmap_mode_scanline(running_machine &machine, gba_state *s
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -70,17 +87,17 @@ static void draw_roz_bitmap_mode_scanline(running_machine &machine, gba_state *s
lineMix[x] = color; lineMix[x] = color;
} }
state->m_gfxBG2Changed = 0; m_gfxBG2Changed = 0;
} }
static 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) void 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)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
int effect = state->m_BLDCNT & BLDCNT_SFX; int effect = m_BLDCNT & BLDCNT_SFX;
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); 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);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -106,7 +123,7 @@ static void draw_roz_bitmap_mode_scanline_nowindow(running_machine &machine, gba
case BLDCNT_SFX_NONE: case BLDCNT_SFX_NONE:
break; break;
case BLDCNT_SFX_ALPHA: case BLDCNT_SFX_ALPHA:
if(state->m_BLDCNT & top) if(m_BLDCNT & top)
{ {
UINT32 back = backdrop; UINT32 back = backdrop;
UINT8 top2 = 0x20; UINT8 top2 = 0x20;
@ -129,22 +146,22 @@ static void draw_roz_bitmap_mode_scanline_nowindow(running_machine &machine, gba
} }
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
} }
break; break;
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -160,24 +177,24 @@ static void draw_roz_bitmap_mode_scanline_nowindow(running_machine &machine, gba
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -185,23 +202,23 @@ static void draw_roz_bitmap_mode_scanline_nowindow(running_machine &machine, gba
} }
lineMix[x] = color; lineMix[x] = color;
} }
state->m_gfxBG2Changed = 0; m_gfxBG2Changed = 0;
} }
static 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) void 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)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
int inWindow0 = 0; int inWindow0 = 0;
int inWindow1 = 0; int inWindow1 = 0;
UINT8 inWin0Mask = state->m_WININ & 0x00ff; UINT8 inWin0Mask = m_WININ & 0x00ff;
UINT8 inWin1Mask = state->m_WININ >> 8; UINT8 inWin1Mask = m_WININ >> 8;
UINT8 outMask = state->m_WINOUT & 0x00ff; UINT8 outMask = m_WINOUT & 0x00ff;
if(state->m_DISPCNT & DISPCNT_WIN0_EN) if(m_DISPCNT & DISPCNT_WIN0_EN)
{ {
UINT8 v0 = state->m_WIN0V >> 8; UINT8 v0 = m_WIN0V >> 8;
UINT8 v1 = state->m_WIN0V & 0x00ff; UINT8 v1 = m_WIN0V & 0x00ff;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
if(v1 >= v0) if(v1 >= v0)
{ {
@ -213,10 +230,10 @@ static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_stat
} }
} }
if(state->m_DISPCNT & DISPCNT_WIN1_EN) if(m_DISPCNT & DISPCNT_WIN1_EN)
{ {
UINT8 v0 = state->m_WIN1V >> 8; UINT8 v0 = m_WIN1V >> 8;
UINT8 v1 = state->m_WIN1V & 0x00ff; UINT8 v1 = m_WIN1V & 0x00ff;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
if(v1 >= v0) if(v1 >= v0)
{ {
@ -228,9 +245,9 @@ static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_stat
} }
} }
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); 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);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
draw_gba_oam_window(state, machine, lineOBJWin, y); draw_gba_oam_window(lineOBJWin, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -240,12 +257,12 @@ static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_stat
if((lineOBJWin[x] & 0x80000000) == 0) if((lineOBJWin[x] & 0x80000000) == 0)
{ {
mask = state->m_WINOUT >> 8; mask = m_WINOUT >> 8;
} }
if(inWindow1) if(inWindow1)
{ {
if(is_in_window(state, x, 1)) if(is_in_window(x, 1))
{ {
mask = inWin1Mask; mask = inWin1Mask;
} }
@ -253,7 +270,7 @@ static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_stat
if(inWindow0) if(inWindow0)
{ {
if(is_in_window(state, x, 0)) if(is_in_window(x, 0))
{ {
mask = inWin0Mask; mask = inWin0Mask;
} }
@ -275,13 +292,13 @@ static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_stat
{ {
if((color & 0x00010000) == 0) if((color & 0x00010000) == 0)
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_NONE: case BLDCNT_SFX_NONE:
break; break;
case BLDCNT_SFX_ALPHA: case BLDCNT_SFX_ALPHA:
{ {
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
UINT32 back = backdrop; UINT32 back = backdrop;
UINT8 top2 = 0x20; UINT8 top2 = 0x20;
@ -303,23 +320,23 @@ static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_stat
} }
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
} }
break; break;
} }
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -335,24 +352,24 @@ static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_stat
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -370,24 +387,24 @@ static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_stat
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -395,5 +412,5 @@ static void draw_roz_bitmap_mode_scanline_all(running_machine &machine, gba_stat
} }
lineMix[x] = color; lineMix[x] = color;
} }
state->m_gfxBG2Changed = 0; m_gfxBG2Changed = 0;
} }

View File

@ -1,4 +1,4 @@
/*************************************************************************** /***************************************************************************
gbamode0.c gbamode0.c
@ -8,16 +8,33 @@
***************************************************************************/ ***************************************************************************/
static 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)
void gba_state::draw_mode0(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{
switch (submode)
{
case 0:
draw_mode0_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
case 1:
draw_mode0_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
case 2:
draw_mode0_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
}
}
void gba_state::draw_mode0_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS); draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS); draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
draw_bg_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2HOFS, state->m_BG2VOFS); draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS);
draw_bg_scanline(state, line3, y, DISPCNT_BG3_EN, state->m_BG3CNT, state->m_BG3HOFS, state->m_BG3VOFS); draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -83,24 +100,24 @@ static void draw_mode0_scanline(running_machine &machine, gba_state *state, int
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -111,17 +128,17 @@ static void draw_mode0_scanline(running_machine &machine, gba_state *state, int
} }
} }
static 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) void gba_state::draw_mode0_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
int effect = state->m_BLDCNT & BLDCNT_SFX; int effect = m_BLDCNT & BLDCNT_SFX;
draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS); draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS); draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
draw_bg_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2HOFS, state->m_BG2VOFS); draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS);
draw_bg_scanline(state, line3, y, DISPCNT_BG3_EN, state->m_BG3CNT, state->m_BG3HOFS, state->m_BG3VOFS); draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -165,7 +182,7 @@ static void draw_mode0_scanline_nowindow(running_machine &machine, gba_state *st
case BLDCNT_SFX_NONE: case BLDCNT_SFX_NONE:
break; break;
case BLDCNT_SFX_ALPHA: case BLDCNT_SFX_ALPHA:
if(state->m_BLDCNT & top) if(m_BLDCNT & top)
{ {
UINT32 back = backdrop; UINT32 back = backdrop;
UINT8 top2 = 0x20; UINT8 top2 = 0x20;
@ -215,22 +232,22 @@ static void draw_mode0_scanline_nowindow(running_machine &machine, gba_state *st
} }
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
} }
break; break;
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -264,24 +281,24 @@ static void draw_mode0_scanline_nowindow(running_machine &machine, gba_state *st
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -291,20 +308,20 @@ static void draw_mode0_scanline_nowindow(running_machine &machine, gba_state *st
} }
} }
static 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) void gba_state::draw_mode0_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
int inWindow0 = 0; int inWindow0 = 0;
int inWindow1 = 0; int inWindow1 = 0;
UINT8 inWin0Mask = state->m_WININ & 0x00ff; UINT8 inWin0Mask = m_WININ & 0x00ff;
UINT8 inWin1Mask = state->m_WININ >> 8; UINT8 inWin1Mask = m_WININ >> 8;
UINT8 outMask = state->m_WINOUT & 0x00ff; UINT8 outMask = m_WINOUT & 0x00ff;
if(state->m_DISPCNT & DISPCNT_WIN0_EN) if(m_DISPCNT & DISPCNT_WIN0_EN)
{ {
UINT8 v0 = state->m_WIN0V >> 8; UINT8 v0 = m_WIN0V >> 8;
UINT8 v1 = state->m_WIN0V & 0x00ff; UINT8 v1 = m_WIN0V & 0x00ff;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
if(v1 >= v0) if(v1 >= v0)
{ {
@ -316,10 +333,10 @@ static void draw_mode0_scanline_all(running_machine &machine, gba_state *state,
} }
} }
if(state->m_DISPCNT & DISPCNT_WIN1_EN) if(m_DISPCNT & DISPCNT_WIN1_EN)
{ {
UINT8 v0 = state->m_WIN1V >> 8; UINT8 v0 = m_WIN1V >> 8;
UINT8 v1 = state->m_WIN1V & 0x00ff; UINT8 v1 = m_WIN1V & 0x00ff;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
if(v1 >= v0) if(v1 >= v0)
{ {
@ -331,12 +348,12 @@ static void draw_mode0_scanline_all(running_machine &machine, gba_state *state,
} }
} }
draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS); draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS); draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
draw_bg_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2HOFS, state->m_BG2VOFS); draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS);
draw_bg_scanline(state, line3, y, DISPCNT_BG3_EN, state->m_BG3CNT, state->m_BG3HOFS, state->m_BG3VOFS); draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
draw_gba_oam_window(state, machine, lineOBJWin, y); draw_gba_oam_window(lineOBJWin, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -346,12 +363,12 @@ static void draw_mode0_scanline_all(running_machine &machine, gba_state *state,
if((lineOBJWin[x] & 0x80000000) == 0) if((lineOBJWin[x] & 0x80000000) == 0)
{ {
mask = state->m_WINOUT >> 8; mask = m_WINOUT >> 8;
} }
if(inWindow1) if(inWindow1)
{ {
if(is_in_window(state, x, 1)) if(is_in_window(x, 1))
{ {
mask = inWin1Mask; mask = inWin1Mask;
} }
@ -359,7 +376,7 @@ static void draw_mode0_scanline_all(running_machine &machine, gba_state *state,
if(inWindow0) if(inWindow0)
{ {
if(is_in_window(state, x, 0)) if(is_in_window(x, 0))
{ {
mask = inWin0Mask; mask = inWin0Mask;
} }
@ -399,13 +416,13 @@ static void draw_mode0_scanline_all(running_machine &machine, gba_state *state,
{ {
if((color & 0x00010000) == 0) if((color & 0x00010000) == 0)
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_NONE: case BLDCNT_SFX_NONE:
break; break;
case BLDCNT_SFX_ALPHA: case BLDCNT_SFX_ALPHA:
{ {
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
UINT32 back = backdrop; UINT32 back = backdrop;
UINT8 top2 = 0x20; UINT8 top2 = 0x20;
@ -454,23 +471,23 @@ static void draw_mode0_scanline_all(running_machine &machine, gba_state *state,
} }
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
} }
break; break;
} }
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -504,24 +521,24 @@ static void draw_mode0_scanline_all(running_machine &machine, gba_state *state,
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -557,24 +574,24 @@ static void draw_mode0_scanline_all(running_machine &machine, gba_state *state,
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }

View File

@ -1,4 +1,4 @@
/*************************************************************************** /***************************************************************************
gbamode1.c gbamode1.c
@ -8,15 +8,32 @@
***************************************************************************/ ***************************************************************************/
static 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)
void gba_state::draw_mode1(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{
switch (submode)
{
case 0:
draw_mode1_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
case 1:
draw_mode1_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
case 2:
draw_mode1_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
}
}
void gba_state::draw_mode1_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS); draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS); draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
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); 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);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -70,24 +87,24 @@ static void draw_mode1_scanline(running_machine &machine, gba_state *state, int
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -96,19 +113,19 @@ static void draw_mode1_scanline(running_machine &machine, gba_state *state, int
lineMix[x] = color; lineMix[x] = color;
} }
state->m_gfxBG2Changed = 0; m_gfxBG2Changed = 0;
} }
static 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) void gba_state::draw_mode1_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
int effect = state->m_BLDCNT & BLDCNT_SFX; int effect = m_BLDCNT & BLDCNT_SFX;
draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS); draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS); draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
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); 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);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -146,7 +163,7 @@ static void draw_mode1_scanline_nowindow(running_machine &machine, gba_state *st
case BLDCNT_SFX_NONE: case BLDCNT_SFX_NONE:
break; break;
case BLDCNT_SFX_ALPHA: case BLDCNT_SFX_ALPHA:
if(state->m_BLDCNT & top) if(m_BLDCNT & top)
{ {
UINT32 back = backdrop; UINT32 back = backdrop;
UINT8 top2 = 0x20; UINT8 top2 = 0x20;
@ -187,22 +204,22 @@ static void draw_mode1_scanline_nowindow(running_machine &machine, gba_state *st
} }
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
} }
break; break;
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -230,24 +247,24 @@ static void draw_mode1_scanline_nowindow(running_machine &machine, gba_state *st
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -255,23 +272,23 @@ static void draw_mode1_scanline_nowindow(running_machine &machine, gba_state *st
} }
lineMix[x] = color; lineMix[x] = color;
} }
state->m_gfxBG2Changed = 0; m_gfxBG2Changed = 0;
} }
static 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) void gba_state::draw_mode1_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
int inWindow0 = 0; int inWindow0 = 0;
int inWindow1 = 0; int inWindow1 = 0;
UINT8 inWin0Mask = state->m_WININ & 0x00ff; UINT8 inWin0Mask = m_WININ & 0x00ff;
UINT8 inWin1Mask = state->m_WININ >> 8; UINT8 inWin1Mask = m_WININ >> 8;
UINT8 outMask = state->m_WINOUT & 0x00ff; UINT8 outMask = m_WINOUT & 0x00ff;
if(state->m_DISPCNT & DISPCNT_WIN0_EN) if(m_DISPCNT & DISPCNT_WIN0_EN)
{ {
UINT8 v0 = state->m_WIN0V >> 8; UINT8 v0 = m_WIN0V >> 8;
UINT8 v1 = state->m_WIN0V & 0x00ff; UINT8 v1 = m_WIN0V & 0x00ff;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
if(v1 >= v0) if(v1 >= v0)
{ {
@ -283,10 +300,10 @@ static void draw_mode1_scanline_all(running_machine &machine, gba_state *state,
} }
} }
if(state->m_DISPCNT & DISPCNT_WIN1_EN) if(m_DISPCNT & DISPCNT_WIN1_EN)
{ {
UINT8 v0 = state->m_WIN1V >> 8; UINT8 v0 = m_WIN1V >> 8;
UINT8 v1 = state->m_WIN1V & 0x00ff; UINT8 v1 = m_WIN1V & 0x00ff;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
if(v1 >= v0) if(v1 >= v0)
{ {
@ -298,11 +315,11 @@ static void draw_mode1_scanline_all(running_machine &machine, gba_state *state,
} }
} }
draw_bg_scanline(state, line0, y, DISPCNT_BG0_EN, state->m_BG0CNT, state->m_BG0HOFS, state->m_BG0VOFS); draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS);
draw_bg_scanline(state, line1, y, DISPCNT_BG1_EN, state->m_BG1CNT, state->m_BG1HOFS, state->m_BG1VOFS); draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS);
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); 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);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
draw_gba_oam_window(state, machine, lineOBJWin, y); draw_gba_oam_window(lineOBJWin, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -312,12 +329,12 @@ static void draw_mode1_scanline_all(running_machine &machine, gba_state *state,
if((lineOBJWin[x] & 0x80000000) == 0) if((lineOBJWin[x] & 0x80000000) == 0)
{ {
mask = state->m_WINOUT >> 8; mask = m_WINOUT >> 8;
} }
if(inWindow1) if(inWindow1)
{ {
if(is_in_window(state, x, 1)) if(is_in_window(x, 1))
{ {
mask = inWin1Mask; mask = inWin1Mask;
} }
@ -325,7 +342,7 @@ static void draw_mode1_scanline_all(running_machine &machine, gba_state *state,
if(inWindow0) if(inWindow0)
{ {
if(is_in_window(state, x, 0)) if(is_in_window(x, 0))
{ {
mask = inWin0Mask; mask = inWin0Mask;
} }
@ -359,13 +376,13 @@ static void draw_mode1_scanline_all(running_machine &machine, gba_state *state,
{ {
if((color & 0x00010000) == 0) if((color & 0x00010000) == 0)
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_NONE: case BLDCNT_SFX_NONE:
break; break;
case BLDCNT_SFX_ALPHA: case BLDCNT_SFX_ALPHA:
{ {
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
UINT32 back = backdrop; UINT32 back = backdrop;
UINT8 top2 = 0x20; UINT8 top2 = 0x20;
@ -405,23 +422,23 @@ static void draw_mode1_scanline_all(running_machine &machine, gba_state *state,
} }
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
} }
break; break;
} }
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -449,24 +466,24 @@ static void draw_mode1_scanline_all(running_machine &machine, gba_state *state,
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -496,24 +513,24 @@ static void draw_mode1_scanline_all(running_machine &machine, gba_state *state,
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -521,5 +538,5 @@ static void draw_mode1_scanline_all(running_machine &machine, gba_state *state,
} }
lineMix[x] = color; lineMix[x] = color;
} }
state->m_gfxBG2Changed = 0; m_gfxBG2Changed = 0;
} }

View File

@ -1,4 +1,4 @@
/*************************************************************************** /***************************************************************************
gbamode2.c gbamode2.c
@ -8,14 +8,31 @@
***************************************************************************/ ***************************************************************************/
static 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)
void gba_state::draw_mode2(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{
switch (submode)
{
case 0:
draw_mode2_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
case 1:
draw_mode2_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
case 2:
draw_mode2_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp);
break;
}
}
void gba_state::draw_mode2_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
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); 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);
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); 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);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -57,24 +74,24 @@ static void draw_mode2_scanline(running_machine &machine, gba_state *state, int
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -83,19 +100,19 @@ static void draw_mode2_scanline(running_machine &machine, gba_state *state, int
lineMix[x] = color; lineMix[x] = color;
} }
state->m_gfxBG2Changed = 0; m_gfxBG2Changed = 0;
state->m_gfxBG3Changed = 0; m_gfxBG3Changed = 0;
} }
static 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) void gba_state::draw_mode2_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
int effect = state->m_BLDCNT & BLDCNT_SFX; int effect = m_BLDCNT & BLDCNT_SFX;
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); 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);
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); 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);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -127,7 +144,7 @@ static void draw_mode2_scanline_nowindow(running_machine &machine, gba_state *st
case BLDCNT_SFX_NONE: case BLDCNT_SFX_NONE:
break; break;
case BLDCNT_SFX_ALPHA: case BLDCNT_SFX_ALPHA:
if(state->m_BLDCNT & top) if(m_BLDCNT & top)
{ {
UINT32 back = backdrop; UINT32 back = backdrop;
UINT8 top2 = 0x20; UINT8 top2 = 0x20;
@ -159,22 +176,22 @@ static void draw_mode2_scanline_nowindow(running_machine &machine, gba_state *st
} }
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
} }
break; break;
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -196,24 +213,24 @@ static void draw_mode2_scanline_nowindow(running_machine &machine, gba_state *st
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -221,24 +238,24 @@ static void draw_mode2_scanline_nowindow(running_machine &machine, gba_state *st
} }
lineMix[x] = color; lineMix[x] = color;
} }
state->m_gfxBG2Changed = 0; m_gfxBG2Changed = 0;
state->m_gfxBG3Changed = 0; m_gfxBG3Changed = 0;
} }
static 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) void gba_state::draw_mode2_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{ {
int x = 0; int x = 0;
UINT32 backdrop = ((UINT16*)state->m_gba_pram.target())[0] | 0x30000000; UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000;
int inWindow0 = 0; int inWindow0 = 0;
int inWindow1 = 0; int inWindow1 = 0;
UINT8 inWin0Mask = state->m_WININ & 0x00ff; UINT8 inWin0Mask = m_WININ & 0x00ff;
UINT8 inWin1Mask = state->m_WININ >> 8; UINT8 inWin1Mask = m_WININ >> 8;
UINT8 outMask = state->m_WINOUT & 0x00ff; UINT8 outMask = m_WINOUT & 0x00ff;
if(state->m_DISPCNT & DISPCNT_WIN0_EN) if(m_DISPCNT & DISPCNT_WIN0_EN)
{ {
UINT8 v0 = state->m_WIN0V >> 8; UINT8 v0 = m_WIN0V >> 8;
UINT8 v1 = state->m_WIN0V & 0x00ff; UINT8 v1 = m_WIN0V & 0x00ff;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
if(v1 >= v0) if(v1 >= v0)
{ {
@ -250,10 +267,10 @@ static void draw_mode2_scanline_all(running_machine &machine, gba_state *state,
} }
} }
if(state->m_DISPCNT & DISPCNT_WIN1_EN) if(m_DISPCNT & DISPCNT_WIN1_EN)
{ {
UINT8 v0 = state->m_WIN1V >> 8; UINT8 v0 = m_WIN1V >> 8;
UINT8 v1 = state->m_WIN1V & 0x00ff; UINT8 v1 = m_WIN1V & 0x00ff;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0;
if(v1 >= v0) if(v1 >= v0)
{ {
@ -265,10 +282,10 @@ static void draw_mode2_scanline_all(running_machine &machine, gba_state *state,
} }
} }
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); 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);
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); 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);
draw_gba_oam(state, machine, lineOBJ, y); draw_gba_oam(lineOBJ, y);
draw_gba_oam_window(state, machine, lineOBJWin, y); draw_gba_oam_window(lineOBJWin, y);
for(x = 0; x < 240; x++) for(x = 0; x < 240; x++)
{ {
@ -278,12 +295,12 @@ static void draw_mode2_scanline_all(running_machine &machine, gba_state *state,
if((lineOBJWin[x] & 0x80000000) == 0) if((lineOBJWin[x] & 0x80000000) == 0)
{ {
mask = state->m_WINOUT >> 8; mask = m_WINOUT >> 8;
} }
if(inWindow1) if(inWindow1)
{ {
if(is_in_window(state, x, 1)) if(is_in_window(x, 1))
{ {
mask = inWin1Mask; mask = inWin1Mask;
} }
@ -291,7 +308,7 @@ static void draw_mode2_scanline_all(running_machine &machine, gba_state *state,
if(inWindow0) if(inWindow0)
{ {
if(is_in_window(state, x, 0)) if(is_in_window(x, 0))
{ {
mask = inWin0Mask; mask = inWin0Mask;
} }
@ -319,13 +336,13 @@ static void draw_mode2_scanline_all(running_machine &machine, gba_state *state,
{ {
if((color & 0x00010000) == 0) if((color & 0x00010000) == 0)
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_NONE: case BLDCNT_SFX_NONE:
break; break;
case BLDCNT_SFX_ALPHA: case BLDCNT_SFX_ALPHA:
{ {
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
UINT32 back = backdrop; UINT32 back = backdrop;
UINT8 top2 = 0x20; UINT8 top2 = 0x20;
@ -356,23 +373,23 @@ static void draw_mode2_scanline_all(running_machine &machine, gba_state *state,
} }
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
} }
break; break;
} }
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -394,24 +411,24 @@ static void draw_mode2_scanline_all(running_machine &machine, gba_state *state,
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -435,24 +452,24 @@ static void draw_mode2_scanline_all(running_machine &machine, gba_state *state,
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT)) if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT))
{ {
color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]); color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]);
} }
else else
{ {
switch(state->m_BLDCNT & BLDCNT_SFX) switch(m_BLDCNT & BLDCNT_SFX)
{ {
case BLDCNT_SFX_LIGHTEN: case BLDCNT_SFX_LIGHTEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]); color = increase_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
case BLDCNT_SFX_DARKEN: case BLDCNT_SFX_DARKEN:
if(top & state->m_BLDCNT) if(top & m_BLDCNT)
{ {
color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]); color = decrease_brightness(color, coeff[m_BLDY & 0x1f]);
} }
break; break;
} }
@ -460,6 +477,6 @@ static void draw_mode2_scanline_all(running_machine &machine, gba_state *state,
} }
lineMix[x] = color; lineMix[x] = color;
} }
state->m_gfxBG2Changed = 0; m_gfxBG2Changed = 0;
state->m_gfxBG3Changed = 0; m_gfxBG3Changed = 0;
} }