diff options
author | 2013-04-18 08:44:08 +0000 | |
---|---|---|
committer | 2013-04-18 08:44:08 +0000 | |
commit | f30a3117806c7190217a6a1bccf344ff730a6bb7 (patch) | |
tree | 240d47327de16ed57117be50c49d42c70265dc7c /src/mess/video/wswan.c | |
parent | eb0b5a552e90e20fd042ee694078a8f76e1513ef (diff) |
moving some static functions in driver state for MESS drivers plus some other modernization (nw)
Diffstat (limited to 'src/mess/video/wswan.c')
-rw-r--r-- | src/mess/video/wswan.c | 365 |
1 files changed, 182 insertions, 183 deletions
diff --git a/src/mess/video/wswan.c b/src/mess/video/wswan.c index 12897c6cbfa..21fad625b06 100644 --- a/src/mess/video/wswan.c +++ b/src/mess/video/wswan.c @@ -11,65 +11,66 @@ #include "includes/wswan.h" -static void wswan_setup_palettes(wswan_state *state) { +void wswan_state::wswan_setup_palettes() +{ int i,j; - if ( state->m_vdp.color_mode ) { + if ( m_vdp.color_mode ) { for( i = 0; i < 16; i++ ) { for( j = 0; j < 16; j++ ) { - state->m_pal[i][j] = ( ( state->m_vdp.palette_vram[ ( i << 5 ) + j*2 + 1 ] << 8 ) | state->m_vdp.palette_vram[ ( i << 5 ) + j*2 ] ) & 0x0FFF; + m_pal[i][j] = ( ( m_vdp.palette_vram[ ( i << 5 ) + j*2 + 1 ] << 8 ) | m_vdp.palette_vram[ ( i << 5 ) + j*2 ] ) & 0x0FFF; } } } else { for( i = 0; i < 16; i++ ) { - state->m_pal[i][0] = state->m_ws_portram[ 0x20 + ( i << 1 ) ] & 0x07; - state->m_pal[i][1] = ( state->m_ws_portram[ 0x20 + ( i << 1 ) ] >> 4 ) & 0x07; - state->m_pal[i][2] = state->m_ws_portram[ 0x21 + ( i << 1 ) ] & 0x07; - state->m_pal[i][3] = ( state->m_ws_portram[ 0x21 + ( i << 1 ) ] >> 4 ) & 0x07; + m_pal[i][0] = m_ws_portram[ 0x20 + ( i << 1 ) ] & 0x07; + m_pal[i][1] = ( m_ws_portram[ 0x20 + ( i << 1 ) ] >> 4 ) & 0x07; + m_pal[i][2] = m_ws_portram[ 0x21 + ( i << 1 ) ] & 0x07; + m_pal[i][3] = ( m_ws_portram[ 0x21 + ( i << 1 ) ] >> 4 ) & 0x07; } } } -static void wswan_draw_background( running_machine &machine ) { - wswan_state *state = machine.driver_data<wswan_state>(); +void wswan_state::wswan_draw_background() +{ UINT16 map_addr; UINT8 start_column; int column; - map_addr = state->m_vdp.layer_bg_address + ( ( ( state->m_vdp.current_line + state->m_vdp.layer_bg_scroll_y ) & 0xF8 ) << 3 ); - start_column = ( state->m_vdp.layer_bg_scroll_x >> 3 ); + map_addr = m_vdp.layer_bg_address + ( ( ( m_vdp.current_line + m_vdp.layer_bg_scroll_y ) & 0xF8 ) << 3 ); + start_column = ( m_vdp.layer_bg_scroll_x >> 3 ); for( column = 0; column < 29; column++ ) { int tile_data, tile_number, tile_palette, tile_line, tile_address; UINT32 plane0=0, plane1=0, plane2=0, plane3=0; int x, x_offset; - tile_data = ( state->m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) - | state->m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; + tile_data = ( m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) + | m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; tile_number = tile_data & 0x01FF; tile_palette = ( tile_data >> 9 ) & 0x0F; - tile_line = ( state->m_vdp.current_line + state->m_vdp.layer_bg_scroll_y ) & 0x07; + tile_line = ( m_vdp.current_line + m_vdp.layer_bg_scroll_y ) & 0x07; if ( tile_data & 0x8000 ) { tile_line = 7 - tile_line; } - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.colors_16 ) { tile_address = ( ( tile_data & 0x2000 ) ? 0x8000 : 0x4000 ) + ( tile_number * 32 ) + ( tile_line << 2 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 24 ) | ( state->m_vdp.vram[ tile_address + 1 ] << 16 ) | ( state->m_vdp.vram[ tile_address + 2 ] << 8 ) | state->m_vdp.vram[ tile_address + 3 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 24 ) | ( m_vdp.vram[ tile_address + 1 ] << 16 ) | ( m_vdp.vram[ tile_address + 2 ] << 8 ) | m_vdp.vram[ tile_address + 3 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; - plane2 = state->m_vdp.vram[ tile_address + 2 ] << 2; - plane3 = state->m_vdp.vram[ tile_address + 3 ] << 3; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; + plane2 = m_vdp.vram[ tile_address + 2 ] << 2; + plane3 = m_vdp.vram[ tile_address + 3 ] << 3; } } else { tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 8 ) | state->m_vdp.vram[ tile_address + 1 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 8 ) | m_vdp.vram[ tile_address + 1 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; plane2 = 0; plane3 = 0; } @@ -77,8 +78,8 @@ static void wswan_draw_background( running_machine &machine ) { for( x = 0; x < 8; x++ ) { int col; - if ( state->m_vdp.tile_packed ) { - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.tile_packed ) { + if ( m_vdp.colors_16 ) { col = plane0 & 0x0F; plane0 = plane0 >> 4; } else { @@ -93,26 +94,26 @@ static void wswan_draw_background( running_machine &machine ) { plane0 = plane0 >> 1; } if ( tile_data & 0x4000 ) { - x_offset = x + ( column << 3 ) - ( state->m_vdp.layer_bg_scroll_x & 0x07 ); + x_offset = x + ( column << 3 ) - ( m_vdp.layer_bg_scroll_x & 0x07 ); } else { - x_offset = 7 - x + ( column << 3 ) - ( state->m_vdp.layer_bg_scroll_x & 0x07 ); + x_offset = 7 - x + ( column << 3 ) - ( m_vdp.layer_bg_scroll_x & 0x07 ); } if ( x_offset >= 0 && x_offset < WSWAN_X_PIXELS ) { - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.colors_16 ) { if ( col ) { - if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } else { /* Hmmmm, what should we do here... Is this correct?? */ - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } } } else { if ( col || !(tile_palette & 4 ) ) { - if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } else { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_vdp.main_palette[state->m_pal[tile_palette][col]]; + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_vdp.main_palette[m_pal[tile_palette][col]]; } } } @@ -121,43 +122,43 @@ static void wswan_draw_background( running_machine &machine ) { } } -static void wswan_draw_foreground_0( running_machine &machine ) { - wswan_state *state = machine.driver_data<wswan_state>(); +void wswan_state::wswan_draw_foreground_0() +{ UINT16 map_addr; UINT8 start_column; int column; - map_addr = state->m_vdp.layer_fg_address + ( ( ( state->m_vdp.current_line + state->m_vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); - start_column = ( state->m_vdp.layer_fg_scroll_x >> 3 ); + map_addr = m_vdp.layer_fg_address + ( ( ( m_vdp.current_line + m_vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); + start_column = ( m_vdp.layer_fg_scroll_x >> 3 ); for( column = 0; column < 29; column++ ) { UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; int x, x_offset, tile_line, tile_address; - int tile_data = ( state->m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) - | state->m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; + int tile_data = ( m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) + | m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; int tile_number = tile_data & 0x01FF; int tile_palette = ( tile_data >> 9 ) & 0x0F; - tile_line = ( state->m_vdp.current_line + state->m_vdp.layer_fg_scroll_y ) & 0x07; + tile_line = ( m_vdp.current_line + m_vdp.layer_fg_scroll_y ) & 0x07; if ( tile_data & 0x8000 ) { tile_line = 7 - tile_line; } - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.colors_16 ) { tile_address = ( ( tile_data & 0x2000 ) ? 0x8000 : 0x4000 ) + ( tile_number * 32 ) + ( tile_line << 2 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 24 ) | ( state->m_vdp.vram[ tile_address + 1 ] << 16 ) | ( state->m_vdp.vram[ tile_address + 2 ] << 8 ) | state->m_vdp.vram[ tile_address + 3 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 24 ) | ( m_vdp.vram[ tile_address + 1 ] << 16 ) | ( m_vdp.vram[ tile_address + 2 ] << 8 ) | m_vdp.vram[ tile_address + 3 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; - plane2 = state->m_vdp.vram[ tile_address + 2 ] << 2; - plane3 = state->m_vdp.vram[ tile_address + 3 ] << 3; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; + plane2 = m_vdp.vram[ tile_address + 2 ] << 2; + plane3 = m_vdp.vram[ tile_address + 3 ] << 3; } } else { tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 8 ) | state->m_vdp.vram[ tile_address + 1 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 8 ) | m_vdp.vram[ tile_address + 1 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; plane2 = 0; plane3 = 0; } @@ -165,8 +166,8 @@ static void wswan_draw_foreground_0( running_machine &machine ) { for( x = 0; x < 8; x++ ) { int col; - if ( state->m_vdp.tile_packed ) { - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.tile_packed ) { + if ( m_vdp.colors_16 ) { col = plane0 & 0x0F; plane0 = plane0 >> 4; } else { @@ -181,26 +182,26 @@ static void wswan_draw_foreground_0( running_machine &machine ) { plane0 = plane0 >> 1; } if ( tile_data & 0x4000 ) { - x_offset = x + ( column << 3 ) - ( state->m_vdp.layer_fg_scroll_x & 0x07 ); + x_offset = x + ( column << 3 ) - ( m_vdp.layer_fg_scroll_x & 0x07 ); } else { - x_offset = 7 - x + ( column << 3 ) - ( state->m_vdp.layer_fg_scroll_x & 0x07 ); + x_offset = 7 - x + ( column << 3 ) - ( m_vdp.layer_fg_scroll_x & 0x07 ); } if ( x_offset >= 0 && x_offset < WSWAN_X_PIXELS ) { - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.colors_16 ) { if ( col ) { -// if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; +// if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; // } else { // /* Hmmmm, what should we do here... Is this correct?? */ -// state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; +// m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; // } } } else { if ( col || !(tile_palette & 4 ) ) { - if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } else { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_vdp.main_palette[state->m_pal[tile_palette][col]]; + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_vdp.main_palette[m_pal[tile_palette][col]]; } } } @@ -209,43 +210,43 @@ static void wswan_draw_foreground_0( running_machine &machine ) { } } -static void wswan_draw_foreground_2( running_machine &machine ) { - wswan_state *state = machine.driver_data<wswan_state>(); +void wswan_state::wswan_draw_foreground_2() +{ UINT16 map_addr; UINT8 start_column; int column; - map_addr = state->m_vdp.layer_fg_address + ( ( ( state->m_vdp.current_line + state->m_vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); - start_column = ( state->m_vdp.layer_fg_scroll_x >> 3 ); + map_addr = m_vdp.layer_fg_address + ( ( ( m_vdp.current_line + m_vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); + start_column = ( m_vdp.layer_fg_scroll_x >> 3 ); for( column = 0; column < 29; column++ ) { UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; int x, x_offset, tile_line, tile_address; - int tile_data = ( state->m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) - | state->m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; + int tile_data = ( m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) + | m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; int tile_number = tile_data & 0x01FF; int tile_palette = ( tile_data >> 9 ) & 0x0F; - tile_line = ( state->m_vdp.current_line + state->m_vdp.layer_fg_scroll_y ) & 0x07; + tile_line = ( m_vdp.current_line + m_vdp.layer_fg_scroll_y ) & 0x07; if ( tile_data & 0x8000 ) { tile_line = 7 - tile_line; } - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.colors_16 ) { tile_address = ( ( tile_data & 0x2000 ) ? 0x8000 : 0x4000 ) + ( tile_number * 32 ) + ( tile_line << 2 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 24 ) | ( state->m_vdp.vram[ tile_address + 1 ] << 16 ) | ( state->m_vdp.vram[ tile_address + 2 ] << 8 ) | state->m_vdp.vram[ tile_address + 3 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 24 ) | ( m_vdp.vram[ tile_address + 1 ] << 16 ) | ( m_vdp.vram[ tile_address + 2 ] << 8 ) | m_vdp.vram[ tile_address + 3 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; - plane2 = state->m_vdp.vram[ tile_address + 2 ] << 2; - plane3 = state->m_vdp.vram[ tile_address + 3 ] << 3; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; + plane2 = m_vdp.vram[ tile_address + 2 ] << 2; + plane3 = m_vdp.vram[ tile_address + 3 ] << 3; } } else { tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 8 ) | state->m_vdp.vram[ tile_address + 1 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 8 ) | m_vdp.vram[ tile_address + 1 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; plane2 = 0; plane3 = 0; } @@ -253,8 +254,8 @@ static void wswan_draw_foreground_2( running_machine &machine ) { for( x = 0; x < 8; x++ ) { int col; - if ( state->m_vdp.tile_packed ) { - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.tile_packed ) { + if ( m_vdp.colors_16 ) { col = plane0 & 0x0F; plane0 = plane0 >> 4; } else { @@ -269,26 +270,26 @@ static void wswan_draw_foreground_2( running_machine &machine ) { plane0 = plane0 >> 1; } if ( tile_data & 0x4000 ) { - x_offset = x + ( column << 3 ) - ( state->m_vdp.layer_fg_scroll_x & 0x07 ); + x_offset = x + ( column << 3 ) - ( m_vdp.layer_fg_scroll_x & 0x07 ); } else { - x_offset = 7 - x + ( column << 3 ) - ( state->m_vdp.layer_fg_scroll_x & 0x07 ); + x_offset = 7 - x + ( column << 3 ) - ( m_vdp.layer_fg_scroll_x & 0x07 ); } - if ( x_offset >= 0 && x_offset >= state->m_vdp.window_fg_left && x_offset < state->m_vdp.window_fg_right && x_offset < WSWAN_X_PIXELS ) { - if ( state->m_vdp.colors_16 ) { + if ( x_offset >= 0 && x_offset >= m_vdp.window_fg_left && x_offset < m_vdp.window_fg_right && x_offset < WSWAN_X_PIXELS ) { + if ( m_vdp.colors_16 ) { if ( col ) { - if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } else { /* Hmmmm, what should we do here... Is this correct?? */ - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } } } else { if ( col || !(tile_palette & 4 ) ) { - if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } else { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_vdp.main_palette[state->m_pal[tile_palette][col]]; + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_vdp.main_palette[m_pal[tile_palette][col]]; } } } @@ -297,43 +298,43 @@ static void wswan_draw_foreground_2( running_machine &machine ) { } } -static void wswan_draw_foreground_3( running_machine &machine ) { - wswan_state *state = machine.driver_data<wswan_state>(); +void wswan_state::wswan_draw_foreground_3() +{ UINT16 map_addr; UINT8 start_column; int column; - map_addr = state->m_vdp.layer_fg_address + ( ( ( state->m_vdp.current_line + state->m_vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); - start_column = ( state->m_vdp.layer_fg_scroll_x >> 3 ); + map_addr = m_vdp.layer_fg_address + ( ( ( m_vdp.current_line + m_vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); + start_column = ( m_vdp.layer_fg_scroll_x >> 3 ); for( column = 0; column < 29; column++ ) { UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; int x, x_offset, tile_line, tile_address; - int tile_data = ( state->m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) - | state->m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; + int tile_data = ( m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) + | m_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; int tile_number = tile_data & 0x01FF; int tile_palette = ( tile_data >> 9 ) & 0x0F; - tile_line = ( state->m_vdp.current_line + state->m_vdp.layer_fg_scroll_y ) & 0x07; + tile_line = ( m_vdp.current_line + m_vdp.layer_fg_scroll_y ) & 0x07; if ( tile_data & 0x8000 ) { // vflip tile_line = 7 - tile_line; } - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.colors_16 ) { tile_address = ( ( tile_data & 0x2000 ) ? 0x8000 : 0x4000 ) + ( tile_number * 32 ) + ( tile_line << 2 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 24 ) | ( state->m_vdp.vram[ tile_address + 1 ] << 16 ) | ( state->m_vdp.vram[ tile_address + 2 ] << 8 ) | state->m_vdp.vram[ tile_address + 3 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 24 ) | ( m_vdp.vram[ tile_address + 1 ] << 16 ) | ( m_vdp.vram[ tile_address + 2 ] << 8 ) | m_vdp.vram[ tile_address + 3 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; - plane2 = state->m_vdp.vram[ tile_address + 2 ] << 2; - plane3 = state->m_vdp.vram[ tile_address + 3 ] << 3; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; + plane2 = m_vdp.vram[ tile_address + 2 ] << 2; + plane3 = m_vdp.vram[ tile_address + 3 ] << 3; } } else { tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 8 ) | state->m_vdp.vram[ tile_address + 1 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 8 ) | m_vdp.vram[ tile_address + 1 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; plane2 = 0; plane3 = 0; } @@ -341,8 +342,8 @@ static void wswan_draw_foreground_3( running_machine &machine ) { for( x = 0; x < 8; x++ ) { int col; - if ( state->m_vdp.tile_packed ) { - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.tile_packed ) { + if ( m_vdp.colors_16 ) { col = plane0 & 0x0F; plane0 = plane0 >> 4; } else { @@ -357,26 +358,26 @@ static void wswan_draw_foreground_3( running_machine &machine ) { plane0 = plane0 >> 1; } if ( tile_data & 0x4000 ) { - x_offset = x + ( column << 3 ) - ( state->m_vdp.layer_fg_scroll_x & 0x07 ); + x_offset = x + ( column << 3 ) - ( m_vdp.layer_fg_scroll_x & 0x07 ); } else { - x_offset = 7 - x + ( column << 3 ) - ( state->m_vdp.layer_fg_scroll_x & 0x07 ); + x_offset = 7 - x + ( column << 3 ) - ( m_vdp.layer_fg_scroll_x & 0x07 ); } - if ( ( x_offset >= 0 && x_offset < state->m_vdp.window_fg_left ) || ( x_offset >= state->m_vdp.window_fg_right && x_offset < WSWAN_X_PIXELS ) ) { - if ( state->m_vdp.colors_16 ) { + if ( ( x_offset >= 0 && x_offset < m_vdp.window_fg_left ) || ( x_offset >= m_vdp.window_fg_right && x_offset < WSWAN_X_PIXELS ) ) { + if ( m_vdp.colors_16 ) { if ( col ) { - if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } else { /* Hmmmm, what should we do here... Is this correct?? */ - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } } } else { if ( col || !(tile_palette & 4 ) ) { - if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } else { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_vdp.main_palette[state->m_pal[tile_palette][col]]; + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_vdp.main_palette[m_pal[tile_palette][col]]; } } } @@ -385,20 +386,20 @@ static void wswan_draw_foreground_3( running_machine &machine ) { } } -static void wswan_handle_sprites( running_machine &machine, int mask ) { - wswan_state *state = machine.driver_data<wswan_state>(); +void wswan_state::wswan_handle_sprites(int mask ) +{ int i; - if ( state->m_vdp.sprite_count == 0 ) + if ( m_vdp.sprite_count == 0 ) return; - for( i = state->m_vdp.sprite_first + state->m_vdp.sprite_count - 1; i >= state->m_vdp.sprite_first; i-- ) { + for( i = m_vdp.sprite_first + m_vdp.sprite_count - 1; i >= m_vdp.sprite_first; i-- ) { UINT8 x, y; UINT16 tile_data; int tile_line; - tile_data = ( state->m_vdp.sprite_table_buffer[ i * 4 + 1 ] << 8 ) | state->m_vdp.sprite_table_buffer[ i * 4 ]; - y = state->m_vdp.sprite_table_buffer[ i * 4 + 2 ]; - x = state->m_vdp.sprite_table_buffer[ i * 4 + 3 ]; - tile_line = state->m_vdp.current_line - y; + tile_data = ( m_vdp.sprite_table_buffer[ i * 4 + 1 ] << 8 ) | m_vdp.sprite_table_buffer[ i * 4 ]; + y = m_vdp.sprite_table_buffer[ i * 4 + 2 ]; + x = m_vdp.sprite_table_buffer[ i * 4 + 3 ]; + tile_line = m_vdp.current_line - y; tile_line = tile_line & 0xFF; if ( ( tile_line >= 0 ) && ( tile_line < 8 ) && ( ( tile_data & 0x2000 ) == mask ) ) { UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; @@ -410,35 +411,35 @@ static void wswan_handle_sprites( running_machine &machine, int mask ) { tile_line = 7 - tile_line; } - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.colors_16 ) { tile_address = 0x4000 + ( tile_number * 32 ) + ( tile_line << 2 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 24 ) | ( state->m_vdp.vram[ tile_address + 1 ] << 16 ) | ( state->m_vdp.vram[ tile_address + 2 ] << 8 ) | state->m_vdp.vram[ tile_address + 3 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 24 ) | ( m_vdp.vram[ tile_address + 1 ] << 16 ) | ( m_vdp.vram[ tile_address + 2 ] << 8 ) | m_vdp.vram[ tile_address + 3 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; - plane2 = state->m_vdp.vram[ tile_address + 2 ] << 2; - plane3 = state->m_vdp.vram[ tile_address + 3 ] << 3; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; + plane2 = m_vdp.vram[ tile_address + 2 ] << 2; + plane3 = m_vdp.vram[ tile_address + 3 ] << 3; } } else { tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); - if ( state->m_vdp.tile_packed ) { - plane0 = ( state->m_vdp.vram[ tile_address + 0 ] << 8 ) | state->m_vdp.vram[ tile_address + 1 ]; + if ( m_vdp.tile_packed ) { + plane0 = ( m_vdp.vram[ tile_address + 0 ] << 8 ) | m_vdp.vram[ tile_address + 1 ]; } else { - plane0 = state->m_vdp.vram[ tile_address + 0 ]; - plane1 = state->m_vdp.vram[ tile_address + 1 ] << 1; + plane0 = m_vdp.vram[ tile_address + 0 ]; + plane1 = m_vdp.vram[ tile_address + 1 ] << 1; plane2 = 0; plane3 = 0; } } - if ( state->m_vdp.window_sprites_enable ) { + if ( m_vdp.window_sprites_enable ) { if ( tile_data & 0x1000 ) { - if ( state->m_vdp.current_line >= state->m_vdp.window_sprites_top && state->m_vdp.current_line <= state->m_vdp.window_sprites_bottom ) { + if ( m_vdp.current_line >= m_vdp.window_sprites_top && m_vdp.current_line <= m_vdp.window_sprites_bottom ) { check_clip = 1; } } else { - if ( state->m_vdp.current_line < state->m_vdp.window_sprites_top || state->m_vdp.current_line > state->m_vdp.window_sprites_bottom ) { + if ( m_vdp.current_line < m_vdp.window_sprites_top || m_vdp.current_line > m_vdp.window_sprites_bottom ) { continue; } } @@ -446,8 +447,8 @@ static void wswan_handle_sprites( running_machine &machine, int mask ) { for ( j = 0; j < 8; j++ ) { int col; - if ( state->m_vdp.tile_packed ) { - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.tile_packed ) { + if ( m_vdp.colors_16 ) { col = plane0 & 0x0F; plane0 = plane0 >> 4; } else { @@ -467,33 +468,33 @@ static void wswan_handle_sprites( running_machine &machine, int mask ) { x_offset = x + 7 - j; } x_offset = x_offset & 0xFF; - if ( state->m_vdp.window_sprites_enable ) { + if ( m_vdp.window_sprites_enable ) { if ( tile_data & 0x1000 && check_clip ) { - if ( x_offset >= state->m_vdp.window_sprites_left && x_offset <= state->m_vdp.window_sprites_right ) { + if ( x_offset >= m_vdp.window_sprites_left && x_offset <= m_vdp.window_sprites_right ) { continue; } } else { - if ( x_offset < state->m_vdp.window_sprites_left || x_offset > state->m_vdp.window_sprites_right ) { + if ( x_offset < m_vdp.window_sprites_left || x_offset > m_vdp.window_sprites_right ) { // continue; } } } if ( x_offset >= 0 && x_offset < WSWAN_X_PIXELS ) { - if ( state->m_vdp.colors_16 ) { + if ( m_vdp.colors_16 ) { if ( col ) { - if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } else { /* Hmmmm, what should we do here... Is this correct?? */ - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } } } else { if ( col || !(tile_palette & 4 ) ) { - if ( state->m_vdp.color_mode ) { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_pal[tile_palette][col]; + if ( m_vdp.color_mode ) { + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_pal[tile_palette][col]; } else { - state->m_bitmap.pix16(state->m_vdp.current_line, x_offset) = state->m_vdp.main_palette[state->m_pal[tile_palette][col]]; + m_bitmap.pix16(m_vdp.current_line, x_offset) = m_vdp.main_palette[m_pal[tile_palette][col]]; } } } @@ -503,60 +504,58 @@ static void wswan_handle_sprites( running_machine &machine, int mask ) { } } -void wswan_refresh_scanline( running_machine &machine ) +void wswan_state::wswan_refresh_scanline() { - wswan_state *state = machine.driver_data<wswan_state>(); - - wswan_setup_palettes(state); + wswan_setup_palettes(); - rectangle rec(0, WSWAN_X_PIXELS, state->m_vdp.current_line, state->m_vdp.current_line); - if ( state->m_ws_portram[0x14] ) { + rectangle rec(0, WSWAN_X_PIXELS, m_vdp.current_line, m_vdp.current_line); + if ( m_ws_portram[0x14] ) { /* Not sure if these background color checks and settings are correct */ - if ( state->m_vdp.color_mode && state->m_vdp.colors_16 ) { - state->m_bitmap.fill( state->m_pal[state->m_ws_portram[0x01]>>4][state->m_ws_portram[0x01]&0x0F], rec ); + if ( m_vdp.color_mode && m_vdp.colors_16 ) { + m_bitmap.fill( m_pal[m_ws_portram[0x01]>>4][m_ws_portram[0x01]&0x0F], rec ); } else { - state->m_bitmap.fill( state->m_vdp.main_palette[state->m_ws_portram[0x01]&0x07], rec ); + m_bitmap.fill( m_vdp.main_palette[m_ws_portram[0x01]&0x07], rec ); } } else { - state->m_bitmap.fill( 0, rec ); + m_bitmap.fill( 0, rec ); return; } /* * Draw background layer */ - if ( state->m_vdp.layer_bg_enable ) { - wswan_draw_background(machine); + if ( m_vdp.layer_bg_enable ) { + wswan_draw_background(); } /* * Draw sprites between background and foreground layers */ - if ( state->m_vdp.sprites_enable ) { - wswan_handle_sprites( machine, 0 ); + if ( m_vdp.sprites_enable ) { + wswan_handle_sprites(0); } /* * Draw foreground layer, taking window settings into account */ - if ( state->m_vdp.layer_fg_enable ) { - switch( state->m_vdp.window_fg_mode ) { + if ( m_vdp.layer_fg_enable ) { + switch( m_vdp.window_fg_mode ) { case 0: /* FG inside & outside window area */ - wswan_draw_foreground_0(machine); + wswan_draw_foreground_0(); break; case 1: /* ??? */ logerror( "Unknown foreground mode 1 set\n" ); break; case 2: /* FG only inside window area */ - if ( state->m_vdp.current_line >= state->m_vdp.window_fg_top && state->m_vdp.current_line <= state->m_vdp.window_fg_bottom ) { - wswan_draw_foreground_2(machine); + if ( m_vdp.current_line >= m_vdp.window_fg_top && m_vdp.current_line <= m_vdp.window_fg_bottom ) { + wswan_draw_foreground_2(); } break; case 3: /* FG only outside window area */ - if ( state->m_vdp.current_line < state->m_vdp.window_fg_top || state->m_vdp.current_line > state->m_vdp.window_fg_bottom ) { - wswan_draw_foreground_0(machine); + if ( m_vdp.current_line < m_vdp.window_fg_top || m_vdp.current_line > m_vdp.window_fg_bottom ) { + wswan_draw_foreground_0(); } else { - wswan_draw_foreground_3(machine); + wswan_draw_foreground_3(); } break; } @@ -565,8 +564,8 @@ void wswan_refresh_scanline( running_machine &machine ) /* * Draw sprites in front of foreground layer */ - if ( state->m_vdp.sprites_enable ) { - wswan_handle_sprites( machine, 0x2000 ); + if ( m_vdp.sprites_enable ) { + wswan_handle_sprites(0x2000 ); } } |