From bccaf3156b1fb86018fb5760320278088675aecc Mon Sep 17 00:00:00 2001 From: Zsolt Vasvari Date: Sun, 17 Feb 2008 03:19:01 +0000 Subject: [PATCH] - Color table removal - Converted SNES (except debug code) to RGB32 as it was a serious abuser of the palette system --- src/mame/drivers/cvs.c | 2 + src/mame/drivers/kinstb.c | 21 +-- src/mame/drivers/namcos21.c | 1 - src/mame/drivers/nmk16.c | 37 ++---- src/mame/drivers/nss.c | 21 +-- src/mame/includes/snes.h | 1 - src/mame/machine/snes.c | 17 +-- src/mame/video/nmk16.c | 67 +++++----- src/mame/video/snes.c | 247 +++++++++++++++++------------------- 9 files changed, 161 insertions(+), 253 deletions(-) diff --git a/src/mame/drivers/cvs.c b/src/mame/drivers/cvs.c index 8ce7d9f3f07..17016589037 100644 --- a/src/mame/drivers/cvs.c +++ b/src/mame/drivers/cvs.c @@ -664,6 +664,7 @@ static INPUT_PORTS_START( cvs_registration ) INPUT_PORTS_END + /************************************* * * Games port definitions @@ -961,6 +962,7 @@ static INPUT_PORTS_START( huncholy ) INPUT_PORTS_END + /************************************* * * Graphics definitions diff --git a/src/mame/drivers/kinstb.c b/src/mame/drivers/kinstb.c index 318a3defa90..eccde15605e 100644 --- a/src/mame/drivers/kinstb.c +++ b/src/mame/drivers/kinstb.c @@ -206,21 +206,6 @@ INPUT_PORTS_END static const struct CustomSound_interface snes_sound_interface = { snes_sh_start }; -static GFXDECODE_START( kinstb ) -GFXDECODE_END - -static PALETTE_INIT( snes ) -{ - int i; - - for( i = 0; i < 32768; i++ ) - palette_set_color_rgb( machine, i, pal5bit(i >> 0), pal5bit(i >> 5), pal5bit(i >> 10) ); - - /* The colortable can be black */ - for( i = 0; i < 256; i++ ) - colortable[i] = 0; -} - static MACHINE_DRIVER_START( kinstb ) /* basic machine hardware */ MDRV_CPU_ADD_TAG("main", G65816, 3580000) /* 2.68Mhz, also 3.58Mhz */ @@ -240,13 +225,9 @@ static MACHINE_DRIVER_START( kinstb ) MDRV_VIDEO_UPDATE( snes ) MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) - MDRV_GFXDECODE(kinstb) - MDRV_PALETTE_LENGTH(32768) - MDRV_COLORTABLE_LENGTH(257) - MDRV_PALETTE_INIT( snes ) MDRV_SCREEN_ADD("main", 0) - MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) + MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) MDRV_SCREEN_RAW_PARAMS(DOTCLK_NTSC, SNES_HTOTAL, 0, SNES_SCR_WIDTH, SNES_VTOTAL_NTSC, 0, SNES_SCR_HEIGHT_NTSC) /* sound hardware */ diff --git a/src/mame/drivers/namcos21.c b/src/mame/drivers/namcos21.c index 7da9a0f6c65..a2f818be6dd 100644 --- a/src/mame/drivers/namcos21.c +++ b/src/mame/drivers/namcos21.c @@ -1685,7 +1685,6 @@ static MACHINE_DRIVER_START( winrun_c140_typeB ) MDRV_SCREEN_VISIBLE_AREA(0,495,0,479) MDRV_PALETTE_LENGTH(NAMCOS21_NUM_COLORS) - MDRV_COLORTABLE_LENGTH(NAMCOS21_NUM_COLORS) MDRV_VIDEO_START(namcos21) MDRV_VIDEO_UPDATE(namcos21) diff --git a/src/mame/drivers/nmk16.c b/src/mame/drivers/nmk16.c index af6cf8202e6..5fe76ab5101 100644 --- a/src/mame/drivers/nmk16.c +++ b/src/mame/drivers/nmk16.c @@ -246,9 +246,8 @@ WRITE16_HANDLER( afega_vram_0_w ); WRITE16_HANDLER( afega_vram_1_w ); //WRITE16_HANDLER( afega_palette_w ); -PALETTE_INIT( grdnstrm ); - VIDEO_START( afega ); +VIDEO_START( grdnstrm ); VIDEO_START( firehawk ); VIDEO_UPDATE( afega ); VIDEO_UPDATE( redhawkb ); @@ -4962,7 +4961,7 @@ static const gfx_layout layout_16x16x4_swapped = }; static GFXDECODE_START( grdnstrm ) - GFXDECODE_ENTRY( REGION_GFX2, 0, layout_16x16x8, 256*3, 16 ) // [1] Layer 0 + GFXDECODE_ENTRY( REGION_GFX2, 0, layout_16x16x8, 256*0, 1 ) // [1] Layer 0 GFXDECODE_ENTRY( REGION_GFX3, 0, layout_8x8x4, 256*2, 16 ) // [2] Layer 1 GFXDECODE_ENTRY( REGION_GFX1, 0, layout_16x16x4, 256*1, 16 ) // [0] Sprites GFXDECODE_END @@ -5055,30 +5054,11 @@ static MACHINE_DRIVER_START( grdnstrm ) /* video hardware */ MDRV_GFXDECODE(grdnstrm) - MDRV_PALETTE_LENGTH(768) - MDRV_COLORTABLE_LENGTH(768 + 16*256) - - MDRV_PALETTE_INIT(grdnstrm) + MDRV_VIDEO_START(grdnstrm) MACHINE_DRIVER_END static MACHINE_DRIVER_START( popspops ) - /* basic machine hardware */ - MDRV_IMPORT_FROM(stagger1) - - /* video hardware */ - MDRV_GFXDECODE(grdnstrm) - MDRV_PALETTE_LENGTH(768) - MDRV_COLORTABLE_LENGTH(768 + 16*256) - - MDRV_PALETTE_INIT(grdnstrm) - - MDRV_VIDEO_UPDATE(bubl2000) -MACHINE_DRIVER_END - - -static MACHINE_DRIVER_START( bubl2000 ) - /* basic machine hardware */ MDRV_IMPORT_FROM(grdnstrm) @@ -5086,6 +5066,7 @@ static MACHINE_DRIVER_START( bubl2000 ) MDRV_VIDEO_UPDATE(bubl2000) MACHINE_DRIVER_END + static MACHINE_DRIVER_START( firehawk ) /* basic machine hardware */ @@ -5107,9 +5088,7 @@ static MACHINE_DRIVER_START( firehawk ) MDRV_GFXDECODE(grdnstrm) MDRV_PALETTE_LENGTH(768) - MDRV_COLORTABLE_LENGTH(768 + 16*256) - MDRV_PALETTE_INIT(grdnstrm) MDRV_VIDEO_START(firehawk) MDRV_VIDEO_UPDATE(firehawk) MDRV_VIDEO_EOF(nmk) @@ -6944,14 +6923,14 @@ GAME( 1996, airattca, airattck,ssmissin, airattck, ssmissin, ROT270, "Comad", // afega & clones GAME( 1995, twinactn, 0, twinactn, twinactn, 0, ROT0, "Afega", "Twin Action", 0 ) +GAME( 1998, stagger1, 0, stagger1, stagger1, 0, ROT270, "Afega", "Stagger I (Japan)", 0 ) GAME( 1997, redhawk, stagger1, stagger1, stagger1, redhawk, ROT270, "Afega", "Red Hawk (US)", 0 ) GAME( 1997, redhawkb, stagger1, redhawkb, redhawkb, 0, ROT0, "bootleg", "Red Hawk (bootleg)", 0 ) -GAME( 1998, stagger1, 0, stagger1, stagger1, 0, ROT270, "Afega", "Stagger I (Japan)", 0 ) GAME( 1998, grdnstrm, 0, grdnstrm, grdnstrm, grdnstrm, ROT270, "Afega", "Sen Jin - Guardian Storm (Korea)", 0 ) -GAME( 1998, bubl2000, 0, bubl2000, bubl2000, bubl2000, ROT0, "Tuning", "Bubble 2000", 0 ) // on a tuning board (bootleg?) -GAME( 1998, hotbubl, bubl2000, bubl2000, bubl2000, bubl2000, ROT0, "Pandora", "Hot Bubble" , 0 ) // on an afega board .. +GAME( 1998, bubl2000, 0, popspops, bubl2000, bubl2000, ROT0, "Tuning", "Bubble 2000", 0 ) // on a tuning board (bootleg?) +GAME( 1998, hotbubl, bubl2000, popspops, bubl2000, bubl2000, ROT0, "Pandora", "Hot Bubble" , 0 ) // on an afega board .. GAME( 1999, popspops, 0, popspops, popspops, grdnstrm, ROT0, "Afega", "Pop's Pop's", 0 ) -GAME( 2000, mangchi, 0, bubl2000, mangchi, bubl2000, ROT0, "Afega", "Mang-Chi", 0 ) +GAME( 2000, mangchi, 0, popspops, mangchi, bubl2000, ROT0, "Afega", "Mang-Chi", 0 ) GAME( 2000, spec2k, 0, firehawk, spec2k, spec2k, ORIENTATION_FLIP_Y, "Yonatech", "Spectrum 2000 (Euro)", 0 ) GAME( 2001, firehawk, 0, firehawk, firehawk, 0, ORIENTATION_FLIP_Y, "ESD", "Fire Hawk", 0 ) diff --git a/src/mame/drivers/nss.c b/src/mame/drivers/nss.c index 23c99790ff3..074e91b3f62 100644 --- a/src/mame/drivers/nss.c +++ b/src/mame/drivers/nss.c @@ -446,21 +446,6 @@ INPUT_PORTS_END static const struct CustomSound_interface snes_sound_interface = { snes_sh_start }; -static GFXDECODE_START( nss ) -GFXDECODE_END - -static PALETTE_INIT( snes ) -{ - int i; - - for( i = 0; i < 32768; i++ ) - palette_set_color_rgb( machine, i, pal5bit(i >> 0), pal5bit(i >> 5), pal5bit(i >> 10) ); - - /* The colortable can be black */ - for( i = 0; i < 256; i++ ) - colortable[i] = 0; -} - static MACHINE_DRIVER_START( snes ) /* basic machine hardware */ MDRV_CPU_ADD_TAG("main", G65816, 3580000) /* 2.68Mhz, also 3.58Mhz */ @@ -480,13 +465,9 @@ static MACHINE_DRIVER_START( snes ) MDRV_VIDEO_UPDATE( snes ) MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) - MDRV_GFXDECODE(nss) - MDRV_PALETTE_LENGTH(32768) - MDRV_COLORTABLE_LENGTH(257) - MDRV_PALETTE_INIT( snes ) MDRV_SCREEN_ADD("main", 0) - MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) + MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) MDRV_SCREEN_RAW_PARAMS(DOTCLK_NTSC, SNES_HTOTAL, 0, SNES_SCR_WIDTH, SNES_VTOTAL_NTSC, 0, SNES_SCR_HEIGHT_NTSC) /* sound hardware */ diff --git a/src/mame/includes/snes.h b/src/mame/includes/snes.h index 21ed722de93..ffb29b909b2 100644 --- a/src/mame/includes/snes.h +++ b/src/mame/includes/snes.h @@ -435,7 +435,6 @@ struct SNES_PPU_STRUCT } mode7; UINT8 clipmasks[6][SNES_SCR_WIDTH + 8]; UINT8 update_windows; - UINT8 update_palette; UINT8 update_offsets; UINT8 mode; }; diff --git a/src/mame/machine/snes.c b/src/mame/machine/snes.c index 52a86e55860..ed530b2d202 100644 --- a/src/mame/machine/snes.c +++ b/src/mame/machine/snes.c @@ -287,7 +287,7 @@ static void snes_init_ram(void) memset( snes_vram, 0, SNES_VRAM_SIZE ); /* Init Colour RAM */ - memset( (UINT8 *)snes_cgram, 0, SNES_CGRAM_SIZE ); + memset( (UINT8 *)snes_cgram, 0, SNES_CGRAM_SIZE + 2); /* Init oam RAM */ memset( snes_oam, 0xff, SNES_OAM_SIZE ); @@ -303,7 +303,6 @@ static void snes_init_ram(void) /* Inititialize registers/variables */ snes_ppu.update_windows = 1; - snes_ppu.update_palette = 1; snes_ppu.beam.latch_vert = 0; snes_ppu.beam.latch_horz = 0; snes_ppu.beam.current_vert = 0; @@ -363,7 +362,7 @@ static OPBASE_HANDLER(snes_opbase) MACHINE_START( snes ) { snes_vram = auto_malloc(SNES_VRAM_SIZE); - snes_cgram = auto_malloc(SNES_CGRAM_SIZE); + snes_cgram = auto_malloc(SNES_CGRAM_SIZE + 2); snes_oam = auto_malloc(SNES_OAM_SIZE); memory_set_opbase_handler(0, snes_opbase); memory_set_opbase_handler(1, spc_opbase); @@ -997,7 +996,6 @@ WRITE8_HANDLER( snes_w_io ) switch( offset ) { case INIDISP: /* Initial settings for screen */ - snes_ppu.update_palette = 1; break; case OBSEL: /* Object size and data area designation */ snes_ppu.layer[4].data = ((data & 0x3) * 0x2000) << 1; @@ -1305,7 +1303,6 @@ WRITE8_HANDLER( snes_w_io ) case CGDATA: /* Data for colour RAM */ ((UINT8 *)snes_cgram)[cgram_address] = data; cgram_address = (cgram_address + 1) % (SNES_CGRAM_SIZE - 2); - snes_ppu.update_palette = 1; break; case W12SEL: /* Window mask settings for BG1-2 */ case W34SEL: /* Window mask settings for BG3-4 */ @@ -1344,7 +1341,7 @@ WRITE8_HANDLER( snes_w_io ) { /* Store it in the extra space we made in the CGRAM * It doesn't really go there, but it's as good a place as any. */ - UINT8 r,g,b,fade; + UINT8 r,g,b; /* Get existing value. */ r = snes_cgram[FIXED_COLOUR] & 0x1f; @@ -1358,14 +1355,6 @@ WRITE8_HANDLER( snes_w_io ) if( data & 0x80 ) b = data & 0x1f; snes_cgram[FIXED_COLOUR] = (r | (g << 5) | (b << 10)); - - /* set the palette entry, adjusting to the fade setting */ - fade = (snes_ram[INIDISP] & 0xf) + 1; - r = (r * fade) >> 4; - g = (g * fade) >> 4; - b = (b * fade) >> 4; - /* palette hacks! */ - ((pen_t *)Machine->remapped_colortable)[FIXED_COLOUR] = ((r & 0x1f) | ((g & 0x1f) << 5) | ((b & 0x1f) << 10)); } break; case SETINI: /* Screen mode/video select */ /* FIXME: We only support line count here */ diff --git a/src/mame/video/nmk16.c b/src/mame/video/nmk16.c index 9a7512e3a4a..ed7f986bd24 100644 --- a/src/mame/video/nmk16.c +++ b/src/mame/video/nmk16.c @@ -875,37 +875,6 @@ UINT16 *afega_vram_0, *afega_scroll_0; UINT16 *afega_vram_1, *afega_scroll_1; -/*************************************************************************** - - - Palette - RRRRGGGGBBBB???? - - -***************************************************************************/ - -#ifdef UNUSED_FUNCTION -WRITE16_HANDLER( afega_palette_w ) -{ - int r,g,b; - data = COMBINE_DATA(&paletteram16[offset]); - b = ((data & 0x00F0) >> 3 ) + ((data & 0x0002) >> 1); - g = ((data & 0x0F00) >> 7 ) + ((data & 0x0004) >> 2); - r = ((data & 0xF000) >> 11) + ((data & 0x0008) >> 3); - palette_set_color_rgb( Machine, offset, pal5bit(r) , pal5bit(g) , pal5bit(b) ); -} -#endif - -/* This game uses 8 bit tiles, so it ignores the color codes and just - uses the same 256 colors for every tile */ -PALETTE_INIT( grdnstrm ) -{ - int color, pen; - for( color = 0; color < 16; color++ ) - for( pen = 0; pen < 256; pen++ ) - colortable[color * 256 + pen + 256*3] = 256*0 + pen; -} - - /*************************************************************************** Tilemaps @@ -949,7 +918,7 @@ static TILEMAP_MAPPER( firehawk_tilemap_scan_pages ) static tilemap *tilemap_0, *tilemap_1; -static TILE_GET_INFO( get_tile_info_0 ) +static TILE_GET_INFO( get_tile_info_0_4bit ) { UINT16 code = afega_vram_0[tile_index]; SET_TILE_INFO( @@ -958,6 +927,15 @@ static TILE_GET_INFO( get_tile_info_0 ) (code & 0xf000) >> 12, 0); } +static TILE_GET_INFO( get_tile_info_0_8bit ) +{ + UINT16 code = afega_vram_0[tile_index]; + SET_TILE_INFO( + 0, + code, + 0, + 0); +} static TILE_GET_INFO( get_tile_info_1 ) { UINT16 code = afega_vram_1[tile_index]; @@ -996,7 +974,7 @@ VIDEO_START( afega ) memset(spriteram_old2,0,0x1000); - tilemap_0 = tilemap_create( get_tile_info_0, afega_tilemap_scan_pages, + tilemap_0 = tilemap_create( get_tile_info_0_4bit, afega_tilemap_scan_pages, 16,16, TILES_PER_PAGE_X*PAGES_PER_TMAP_X,TILES_PER_PAGE_Y*PAGES_PER_TMAP_Y); @@ -1010,6 +988,27 @@ VIDEO_START( afega ) } +VIDEO_START( grdnstrm ) +{ + spriteram_old = auto_malloc(0x1000); + spriteram_old2 = auto_malloc(0x1000); + memset(spriteram_old,0,0x1000); + memset(spriteram_old2,0,0x1000); + + + tilemap_0 = tilemap_create( get_tile_info_0_8bit, afega_tilemap_scan_pages, + + 16,16, + TILES_PER_PAGE_X*PAGES_PER_TMAP_X,TILES_PER_PAGE_Y*PAGES_PER_TMAP_Y); + + tilemap_1 = tilemap_create( get_tile_info_1, tilemap_scan_cols, + + 8,8, + 32,32); + + tilemap_set_transparent_pen(tilemap_1,0xf); +} + VIDEO_START( firehawk ) { @@ -1019,7 +1018,7 @@ VIDEO_START( firehawk ) memset(spriteram_old2,0,0x1000); - tilemap_0 = tilemap_create( get_tile_info_0, firehawk_tilemap_scan_pages, + tilemap_0 = tilemap_create( get_tile_info_0_8bit, firehawk_tilemap_scan_pages, 16,16, TILES_PER_PAGE_X*FIREHAWK_PAGES_PER_TMAP_X,TILES_PER_PAGE_Y*FIREHAWK_PAGES_PER_TMAP_Y); diff --git a/src/mame/video/snes.c b/src/mame/video/snes.c index f3b8426720c..11d6a67db95 100644 --- a/src/mame/video/snes.c +++ b/src/mame/video/snes.c @@ -100,16 +100,16 @@ struct DEBUGOPTS static struct DEBUGOPTS debug_options = {5, {0,0,0,0,0,0}, 0, 0, 0}; /* red green blue purple yellow cyan grey white */ static const UINT16 dbg_mode_colours[8] = { 0x1f, 0x3e0, 0x7c00, 0x7c1f, 0x3ff, 0x7fe0, 0x4210, 0x7fff }; -static UINT8 snes_dbg_video(running_machine *machine, mame_bitmap *bitmap, UINT16 curline); +static UINT8 snes_dbg_video(mame_bitmap *bitmap, UINT16 curline); #endif /* SNES_DBG_video */ /* Forward declarations */ -static void snes_update_line_2(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ); -static void snes_update_line_2_hi(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ); -static void snes_update_line_4(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ); -static void snes_update_line_4_hi(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ); -static void snes_update_line_8(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ); -static void snes_update_line_mode7(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ); +static void snes_update_line_2(UINT8 screen, UINT8 layer, UINT16 curline ); +static void snes_update_line_2_hi(UINT8 screen, UINT8 layer, UINT16 curline ); +static void snes_update_line_4(UINT8 screen, UINT8 layer, UINT16 curline ); +static void snes_update_line_4_hi(UINT8 screen, UINT8 layer, UINT16 curline ); +static void snes_update_line_8(UINT8 screen, UINT8 layer, UINT16 curline ); +static void snes_update_line_mode7(UINT8 screen, UINT8 layer, UINT16 curline ); /* Lookup tables */ static const UINT8 table_bgd_pty[2][4][2] = { { {7,10}, {6,9}, {1,4}, {0,3} }, { {3,10}, {1,7}, {0,0}, {0,0} } }; @@ -136,7 +136,7 @@ struct SCANLINE }; struct SNES_MODE_CONFIG { - void (*drawLayer[5])(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline); + void (*drawLayer[5])(UINT8 screen, UINT8 layer, UINT16 curline); UINT8 count; }; @@ -160,7 +160,7 @@ static const struct SNES_MODE_CONFIG snes_modedefs[8] = * Routine for additive/subtractive blending * between the main and sub screens. *****************************************/ -INLINE void snes_draw_blend(running_machine *machine, UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 clip ) +INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 clip ) { #ifdef SNES_DBG_video if( !debug_options.transparency_disabled ) @@ -186,9 +186,9 @@ INLINE void snes_draw_blend(running_machine *machine, UINT16 offset, UINT16 *col } else /* Fixed colour */ { - r = (*colour & 0x1f) + (machine->remapped_colortable[FIXED_COLOUR] & 0x1f); - g = ((*colour & 0x3e0) >> 5) + ((machine->remapped_colortable[FIXED_COLOUR] & 0x3e0) >> 5); - b = ((*colour & 0x7c00) >> 10) + ((machine->remapped_colortable[FIXED_COLOUR] & 0x7c00) >> 10); + r = (*colour & 0x1f) + (snes_cgram[FIXED_COLOUR] & 0x1f); + g = ((*colour & 0x3e0) >> 5) + ((snes_cgram[FIXED_COLOUR] & 0x3e0) >> 5); + b = ((*colour & 0x7c00) >> 10) + ((snes_cgram[FIXED_COLOUR] & 0x7c00) >> 10); if( snes_ram[CGADSUB] & 0x40 ) /* FIXME: We shouldn't halve for the back colour */ { r >>= 1; @@ -220,9 +220,9 @@ INLINE void snes_draw_blend(running_machine *machine, UINT16 offset, UINT16 *col } else /* Fixed colour */ { - r = (*colour & 0x1f) - (machine->remapped_colortable[FIXED_COLOUR] & 0x1f); - g = ((*colour & 0x3e0) >> 5) - ((machine->remapped_colortable[FIXED_COLOUR] & 0x3e0) >> 5); - b = ((*colour & 0x7c00) >> 10) - ((machine->remapped_colortable[FIXED_COLOUR] & 0x7c00) >> 10); + r = (*colour & 0x1f) - (snes_cgram[FIXED_COLOUR] & 0x1f); + g = ((*colour & 0x3e0) >> 5) - ((snes_cgram[FIXED_COLOUR] & 0x3e0) >> 5); + b = ((*colour & 0x7c00) >> 10) - ((snes_cgram[FIXED_COLOUR] & 0x7c00) >> 10); if( r > 0x1f ) r = 0; if( g > 0x1f ) g = 0; if( b > 0x1f ) b = 0; @@ -243,7 +243,7 @@ INLINE void snes_draw_blend(running_machine *machine, UINT16 offset, UINT16 *col * * Draw tiles with 2 bit planes(4 colors) *****************************************/ -INLINE void snes_draw_tile_2(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) +INLINE void snes_draw_tile_2(UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) { UINT8 mask, plane[2]; UINT16 c; @@ -283,9 +283,9 @@ INLINE void snes_draw_tile_2(running_machine *machine, UINT8 screen, UINT8 layer { if( (scanlines[screen].zbuf[ii] <= priority) && (ii >= 0) ) { - c = machine->remapped_colortable[pal + colour]; + c = snes_cgram[pal + colour]; if( screen == MAINSCREEN ) /* Only blend main screens */ - snes_draw_blend(machine, ii, &c, snes_ppu.layer[layer].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); + snes_draw_blend(ii, &c, snes_ppu.layer[layer].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); scanlines[screen].buffer[ii] = c; scanlines[screen].zbuf[ii] = priority; } @@ -298,17 +298,17 @@ INLINE void snes_draw_tile_2(running_machine *machine, UINT8 screen, UINT8 layer * * Draw 2 tiles with 2 bit planes(4 colors) *****************************************/ -INLINE void snes_draw_tile_2x2(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) +INLINE void snes_draw_tile_2x2(UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) { if( flip ) { - snes_draw_tile_2(machine, screen, layer, tileaddr + 16, x, priority, flip, pal ); - snes_draw_tile_2(machine, screen, layer, tileaddr, x + 8, priority, flip, pal ); + snes_draw_tile_2(screen, layer, tileaddr + 16, x, priority, flip, pal ); + snes_draw_tile_2(screen, layer, tileaddr, x + 8, priority, flip, pal ); } else { - snes_draw_tile_2(machine, screen, layer, tileaddr, x, priority, flip, pal ); - snes_draw_tile_2(machine, screen, layer, tileaddr + 16, x + 8, priority, flip, pal ); + snes_draw_tile_2(screen, layer, tileaddr, x, priority, flip, pal ); + snes_draw_tile_2(screen, layer, tileaddr + 16, x + 8, priority, flip, pal ); } } @@ -317,7 +317,7 @@ INLINE void snes_draw_tile_2x2(running_machine *machine, UINT8 screen, UINT8 lay * * Draw tiles with 4 bit planes(16 colors) *****************************************/ -INLINE void snes_draw_tile_4(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) +INLINE void snes_draw_tile_4(UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) { UINT8 mask, plane[4]; UINT16 c; @@ -361,9 +361,9 @@ INLINE void snes_draw_tile_4(running_machine *machine, UINT8 screen, UINT8 layer { if( (scanlines[screen].zbuf[ii] <= priority) && (ii >= 0) ) { - c = machine->remapped_colortable[pal + colour]; + c = snes_cgram[pal + colour]; if( screen == MAINSCREEN ) /* Only blend main screens */ - snes_draw_blend(machine, ii, &c, snes_ppu.layer[layer].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); + snes_draw_blend(ii, &c, snes_ppu.layer[layer].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); scanlines[screen].buffer[ii] = c; scanlines[screen].zbuf[ii] = priority; } @@ -376,17 +376,17 @@ INLINE void snes_draw_tile_4(running_machine *machine, UINT8 screen, UINT8 layer * * Draw 2 tiles with 4 bit planes(16 colors) *****************************************/ -INLINE void snes_draw_tile_4x2(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) +INLINE void snes_draw_tile_4x2(UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) { if( flip ) { - snes_draw_tile_4(machine, screen, layer, tileaddr + 32, x, priority, flip, pal ); - snes_draw_tile_4(machine, screen, layer, tileaddr, x + 8, priority, flip, pal ); + snes_draw_tile_4(screen, layer, tileaddr + 32, x, priority, flip, pal ); + snes_draw_tile_4(screen, layer, tileaddr, x + 8, priority, flip, pal ); } else { - snes_draw_tile_4(machine, screen, layer, tileaddr, x, priority, flip, pal ); - snes_draw_tile_4(machine, screen, layer, tileaddr + 32, x + 8, priority, flip, pal ); + snes_draw_tile_4(screen, layer, tileaddr, x, priority, flip, pal ); + snes_draw_tile_4(screen, layer, tileaddr + 32, x + 8, priority, flip, pal ); } } @@ -395,7 +395,7 @@ INLINE void snes_draw_tile_4x2(running_machine *machine, UINT8 screen, UINT8 lay * * Draw tiles with 8 bit planes(256 colors) *****************************************/ -INLINE void snes_draw_tile_8(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip ) +INLINE void snes_draw_tile_8(UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip ) { UINT8 mask, plane[8]; UINT16 c; @@ -447,9 +447,9 @@ INLINE void snes_draw_tile_8(running_machine *machine, UINT8 screen, UINT8 layer { if( (scanlines[screen].zbuf[ii] <= priority) && (ii >= 0) ) { - c = machine->remapped_colortable[colour]; + c = snes_cgram[colour]; if( screen == MAINSCREEN ) /* Only blend main screens */ - snes_draw_blend(machine, ii, &c, snes_ppu.layer[layer].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); + snes_draw_blend(ii, &c, snes_ppu.layer[layer].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); scanlines[screen].buffer[ii] = c; scanlines[screen].zbuf[ii] = priority; } @@ -462,17 +462,17 @@ INLINE void snes_draw_tile_8(running_machine *machine, UINT8 screen, UINT8 layer * * Draw 2 tiles with 8 bit planes(256 colors) *****************************************/ -INLINE void snes_draw_tile_8x2(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip ) +INLINE void snes_draw_tile_8x2(UINT8 screen, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip ) { if( flip ) { - snes_draw_tile_8(machine, screen, layer, tileaddr + 64, x, priority, flip ); - snes_draw_tile_8(machine, screen, layer, tileaddr, x + 8, priority, flip ); + snes_draw_tile_8(screen, layer, tileaddr + 64, x, priority, flip ); + snes_draw_tile_8(screen, layer, tileaddr, x + 8, priority, flip ); } else { - snes_draw_tile_8(machine, screen, layer, tileaddr, x, priority, flip ); - snes_draw_tile_8(machine, screen, layer, tileaddr + 64, x + 8, priority, flip ); + snes_draw_tile_8(screen, layer, tileaddr, x, priority, flip ); + snes_draw_tile_8(screen, layer, tileaddr + 64, x + 8, priority, flip ); } } @@ -483,7 +483,7 @@ INLINE void snes_draw_tile_8x2(running_machine *machine, UINT8 screen, UINT8 lay * The same as snes_draw_tile_4() except * that it takes a blend parameter. *****************************************/ -INLINE void snes_draw_tile_object(running_machine *machine, UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) +INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) { UINT8 mask, plane[4]; UINT16 c; @@ -527,9 +527,9 @@ INLINE void snes_draw_tile_object(running_machine *machine, UINT8 screen, UINT16 { if( ii >= 0 ) { - c = machine->remapped_colortable[pal + colour]; + c = snes_cgram[pal + colour]; if( blend && screen == MAINSCREEN ) /* Only blend main screens */ - snes_draw_blend(machine, ii, &c, snes_ppu.layer[4].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); + snes_draw_blend(ii, &c, snes_ppu.layer[4].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); scanlines[screen].buffer[ii] = c; scanlines[screen].zbuf[ii] = priority; @@ -546,7 +546,7 @@ INLINE void snes_draw_tile_object(running_machine *machine, UINT8 screen, UINT16 * that it takes a blend parameter. * Wide version. *****************************************/ -INLINE void snes_draw_tile_object_w(running_machine *machine, UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) +INLINE void snes_draw_tile_object_w(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) { UINT8 mask, plane[4]; UINT16 c; @@ -591,9 +591,9 @@ INLINE void snes_draw_tile_object_w(running_machine *machine, UINT8 screen, UINT { if( ii >= 0 ) { - c = machine->remapped_colortable[pal + colour]; + c = snes_cgram[pal + colour]; if( blend && screen == MAINSCREEN ) /* Only blend main screens */ - snes_draw_blend(machine, ii, &c, snes_ppu.layer[4].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); + snes_draw_blend(ii, &c, snes_ppu.layer[4].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); scanlines[screen].buffer[ii] = c; scanlines[screen].zbuf[ii] = priority; @@ -609,7 +609,7 @@ INLINE void snes_draw_tile_object_w(running_machine *machine, UINT8 screen, UINT * * Update an entire line of 2 bit plane tiles. *********************************************/ -static void snes_update_line_2(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ) +static void snes_update_line_2(UINT8 screen, UINT8 layer, UINT16 curline ) { UINT32 tmap, tile; UINT16 ii, vflip, hflip, pal; @@ -722,11 +722,11 @@ static void snes_update_line_2(running_machine *machine, UINT8 screen, UINT8 lay if( tile_size ) { - snes_draw_tile_2x2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal ); + snes_draw_tile_2x2(screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal ); } else { - snes_draw_tile_2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal ); + snes_draw_tile_2(screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal ); } } } @@ -737,7 +737,7 @@ static void snes_update_line_2(running_machine *machine, UINT8 screen, UINT8 lay * Update an entire line of 2 bit plane tiles. * This is the hires version. *********************************************/ -static void snes_update_line_2_hi(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ) +static void snes_update_line_2_hi(UINT8 screen, UINT8 layer, UINT16 curline ) { UINT32 tmap, tile; UINT16 ii, vflip, hflip, pal; @@ -852,18 +852,18 @@ static void snes_update_line_2_hi(running_machine *machine, UINT8 screen, UINT8 { if( hflip ) { - snes_draw_tile_2x2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1) + 16, priority, hflip, pal ); - snes_draw_tile_2x2(machine, screen, layer, snes_ppu.layer[layer].data + ((tile + 2) << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); + snes_draw_tile_2x2(screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1) + 16, priority, hflip, pal ); + snes_draw_tile_2x2(screen, layer, snes_ppu.layer[layer].data + ((tile + 2) << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); } else { - snes_draw_tile_2x2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); - snes_draw_tile_2x2(machine, screen, layer, snes_ppu.layer[layer].data + ((tile + 2) << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1) + 16, priority, hflip, pal ); + snes_draw_tile_2x2(screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); + snes_draw_tile_2x2(screen, layer, snes_ppu.layer[layer].data + ((tile + 2) << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1) + 16, priority, hflip, pal ); } } else { - snes_draw_tile_2x2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); + snes_draw_tile_2x2(screen, layer, snes_ppu.layer[layer].data + (tile << 4) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); } } } @@ -873,7 +873,7 @@ static void snes_update_line_2_hi(running_machine *machine, UINT8 screen, UINT8 * * Update an entire line of 4 bit plane tiles. *********************************************/ -static void snes_update_line_4(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ) +static void snes_update_line_4(UINT8 screen, UINT8 layer, UINT16 curline ) { UINT32 tmap, tile; UINT16 ii, vflip, hflip, pal; @@ -972,11 +972,11 @@ static void snes_update_line_4(running_machine *machine, UINT8 screen, UINT8 lay if( tile_size ) { - snes_draw_tile_4x2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal ); + snes_draw_tile_4x2(screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal ); } else { - snes_draw_tile_4(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal ); + snes_draw_tile_4(screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal ); } } } @@ -987,7 +987,7 @@ static void snes_update_line_4(running_machine *machine, UINT8 screen, UINT8 lay * Update an entire line of 4 bit plane tiles. * This is the hires version *********************************************/ -static void snes_update_line_4_hi(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ) +static void snes_update_line_4_hi(UINT8 screen, UINT8 layer, UINT16 curline ) { UINT32 tmap, tile; UINT16 ii, vflip, hflip, pal; @@ -1089,18 +1089,18 @@ static void snes_update_line_4_hi(running_machine *machine, UINT8 screen, UINT8 { if( hflip ) { - snes_draw_tile_4x2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1) + 16, priority, hflip, pal ); - snes_draw_tile_4x2(machine, screen, layer, snes_ppu.layer[layer].data + ((tile + 2) << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); + snes_draw_tile_4x2(screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1) + 16, priority, hflip, pal ); + snes_draw_tile_4x2(screen, layer, snes_ppu.layer[layer].data + ((tile + 2) << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); } else { - snes_draw_tile_4x2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); - snes_draw_tile_4x2(machine, screen, layer, snes_ppu.layer[layer].data + ((tile + 2) << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1) + 16, priority, hflip, pal ); + snes_draw_tile_4x2(screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); + snes_draw_tile_4x2(screen, layer, snes_ppu.layer[layer].data + ((tile + 2) << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1) + 16, priority, hflip, pal ); } } else { - snes_draw_tile_4x2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); + snes_draw_tile_4x2(screen, layer, snes_ppu.layer[layer].data + (tile << 5) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal ); } } } @@ -1110,7 +1110,7 @@ static void snes_update_line_4_hi(running_machine *machine, UINT8 screen, UINT8 * * Update an entire line of 8 bit plane tiles. *********************************************/ -static void snes_update_line_8(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ) +static void snes_update_line_8(UINT8 screen, UINT8 layer, UINT16 curline ) { UINT32 tmap, tile; UINT16 ii, vflip, hflip, pal; @@ -1208,11 +1208,11 @@ static void snes_update_line_8(running_machine *machine, UINT8 screen, UINT8 lay if( tile_size ) { - snes_draw_tile_8x2(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 6) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip ); + snes_draw_tile_8x2(screen, layer, snes_ppu.layer[layer].data + (tile << 6) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip ); } else { - snes_draw_tile_8(machine, screen, layer, snes_ppu.layer[layer].data + (tile << 6) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip ); + snes_draw_tile_8(screen, layer, snes_ppu.layer[layer].data + (tile << 6) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip ); } } } @@ -1222,7 +1222,7 @@ static void snes_update_line_8(running_machine *machine, UINT8 screen, UINT8 lay * * Update an entire line of mode7 tiles. *********************************************/ -static void snes_update_line_mode7(running_machine *machine, UINT8 screen, UINT8 layer, UINT16 curline ) +static void snes_update_line_mode7(UINT8 screen, UINT8 layer, UINT16 curline ) { UINT32 tiled; INT16 ma, mb, mc, md; @@ -1326,10 +1326,10 @@ static void snes_update_line_mode7(running_machine *machine, UINT8 screen, UINT8 if( snes_ram[CGWSEL] & 0x1 ) clr = ((colour & 0x7) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); else - clr = machine->remapped_colortable[colour]; + clr = snes_cgram[colour]; /* Only blend main screens */ if( screen == MAINSCREEN ) - snes_draw_blend(machine, xpos, &clr, snes_ppu.layer[0].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); /* FIXME: Need to support clip mode */ + snes_draw_blend(xpos, &clr, snes_ppu.layer[0].blend, (snes_ram[CGWSEL] & 0x30) >> 4 ); /* FIXME: Need to support clip mode */ scanlines[screen].buffer[xpos] = clr; scanlines[screen].zbuf[xpos] = table_bgd_pty[1][0][priority]; @@ -1343,7 +1343,7 @@ static void snes_update_line_mode7(running_machine *machine, UINT8 screen, UINT8 * Update an entire line of sprites. * FIXME: We need to support high priority bit *********************************************/ -static void snes_update_objects(running_machine *machine, UINT8 screen, UINT16 curline ) +static void snes_update_objects(UINT8 screen, UINT16 curline ) { INT8 xs, ys; UINT8 line, widemode = 0; @@ -1417,9 +1417,9 @@ static void snes_update_objects(running_machine *machine, UINT8 screen, UINT16 c if( (x + (count << 3) < SNES_SCR_WIDTH + 8) ) { if( widemode ) - snes_draw_tile_object_w(machine, screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend ); + snes_draw_tile_object_w(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend ); else - snes_draw_tile_object(machine, screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend ); + snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend ); } time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ } @@ -1431,9 +1431,9 @@ static void snes_update_objects(running_machine *machine, UINT8 screen, UINT16 c if( (x + (xs << 3) < SNES_SCR_WIDTH + 8) ) { if( widemode ) - snes_draw_tile_object_w(machine, screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend ); + snes_draw_tile_object_w(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend ); else - snes_draw_tile_object(machine, screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend ); + snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend ); } time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ } @@ -1760,33 +1760,6 @@ static void snes_update_windowmasks(void) } } -/********************************************* - * snes_update_palette() - * - * Update the palette with the latest changes. - *********************************************/ -static void snes_update_palette(running_machine *machine) -{ - UINT8 r, g, b, fade; - UINT16 ii; - UINT32 col; - - /* Reset the flag */ - snes_ppu.update_palette = 0; - - /* Modify the palette to fade out the colours */ - fade = (snes_ram[INIDISP] & 0xf) + 1; - for( ii = 0; ii <= 256; ii++ ) - { - col = machine->pens[snes_cgram[ii] & 0x7fff]; - r = ((col & 0x1f) * fade) >> 4; - g = (((col & 0x3e0) >> 5) * fade) >> 4; - b = (((col & 0x7c00) >> 10) * fade) >> 4; - /* palette hacks! */ - ((pen_t *)machine->remapped_colortable)[ii] = ((r & 0x1f) | ((g & 0x1f) << 5) | ((b & 0x1f) << 10)); - } -} - /********************************************* * snes_update_offsets() * @@ -1810,26 +1783,23 @@ static void snes_update_offsets(void) * * Redraw the current line. *********************************************/ -static void snes_refresh_scanline(running_machine *machine, mame_bitmap *bitmap, UINT16 curline ) +static void snes_refresh_scanline(mame_bitmap *bitmap, UINT16 curline ) { UINT16 ii; + int x; + int fade; + struct SCANLINE *scanline; profiler_mark(PROFILER_VIDEO); if( snes_ram[INIDISP] & 0x80 ) /* screen is forced blank */ - { - rectangle r = machine->screen[0].visarea; - r.min_y = r.max_y = curline; - fillbitmap(bitmap, machine->pens[0], &r); - } + for (x = 0; x < SNES_SCR_WIDTH; x++) + *BITMAP_ADDR32(bitmap, curline, x) = RGB_BLACK; else { /* Update clip window masks if necessary */ if( snes_ppu.update_windows ) snes_update_windowmasks(); - /* Update the palette if necessary */ - if( snes_ppu.update_palette ) - snes_update_palette(machine); /* Update the offsets if necessary */ if( snes_ppu.update_offsets ) snes_update_offsets(); @@ -1843,18 +1813,18 @@ static void snes_refresh_scanline(running_machine *machine, mame_bitmap *bitmap, { /* Not sure if this is correct behaviour, but a few games seem to * require it. (SMW, Zelda etc) */ - scanlines[SUBSCREEN].buffer[ii] = machine->remapped_colortable[FIXED_COLOUR]; + scanlines[SUBSCREEN].buffer[ii] = snes_cgram[FIXED_COLOUR]; /* Draw back colour */ - scanlines[MAINSCREEN].buffer[ii] = machine->remapped_colortable[0]; + scanlines[MAINSCREEN].buffer[ii] = snes_cgram[0]; } /* Draw subscreen */ if( snes_ram[TS] & 0x10 ) - snes_update_objects(machine, SUBSCREEN, curline ); + snes_update_objects(SUBSCREEN, curline ); for( ii = 0; ii < snes_modedefs[snes_ppu.mode].count; ii++ ) { if( snes_ram[TS] & (0x1 << ii) ) - snes_modedefs[snes_ppu.mode].drawLayer[ii](machine, SUBSCREEN, ii, curline ); + snes_modedefs[snes_ppu.mode].drawLayer[ii](SUBSCREEN, ii, curline ); } /* Draw the back plane */ #ifdef SNES_DBG_video @@ -1864,20 +1834,20 @@ static void snes_refresh_scanline(running_machine *machine, mame_bitmap *bitmap, { for( ii = 0; ii < SNES_SCR_WIDTH; ii++ ) { - snes_draw_blend(machine, ii, &scanlines[MAINSCREEN].buffer[ii], (snes_ram[CGADSUB] & 0x80)?SNES_BLEND_SUB:SNES_BLEND_ADD, (snes_ram[CGWSEL] & 0x30) >> 4 ); + snes_draw_blend(ii, &scanlines[MAINSCREEN].buffer[ii], (snes_ram[CGADSUB] & 0x80)?SNES_BLEND_SUB:SNES_BLEND_ADD, (snes_ram[CGWSEL] & 0x30) >> 4 ); } } /* Draw mainscreen */ if( snes_ram[TM] & 0x10 ) - snes_update_objects(machine, MAINSCREEN, curline ); + snes_update_objects(MAINSCREEN, curline ); for( ii = 0; ii < snes_modedefs[snes_ppu.mode].count; ii++ ) { if( snes_ram[TM] & (0x1 << ii) ) - snes_modedefs[snes_ppu.mode].drawLayer[ii](machine, MAINSCREEN, ii, curline ); + snes_modedefs[snes_ppu.mode].drawLayer[ii](MAINSCREEN, ii, curline ); } #ifdef SNES_DBG_video - if( snes_dbg_video(machine, bitmap, curline ) ) + if( snes_dbg_video(bitmap, curline ) ) { profiler_mark(PROFILER_END); return; @@ -1885,12 +1855,21 @@ static void snes_refresh_scanline(running_machine *machine, mame_bitmap *bitmap, /* Toggle drawing of subscreen or mainscreen */ if( debug_options.draw_subscreen ) - memcpy( (UINT16 *)bitmap->base + bitmap->rowpixels * curline, scanlines[SUBSCREEN].buffer, (SNES_SCR_WIDTH * 2) * sizeof(UINT16) ); + scanline = &scanlines[SUBSCREEN]; else #endif /* SNES_DBG_video */ + scanline = &scanlines[MAINSCREEN]; /* Phew! Draw the line to screen */ - memcpy( (UINT16 *)bitmap->base + bitmap->rowpixels * curline, scanlines[MAINSCREEN].buffer, (SNES_SCR_WIDTH * 2) * sizeof(UINT16) ); + fade = (snes_ram[INIDISP] & 0xf) + 1; + + for (x = 0; x < SNES_SCR_WIDTH; x++) + { + int r = ((scanline->buffer[x] & 0x1f) * fade) >> 4; + int g = (((scanline->buffer[x] & 0x3e0) >> 5) * fade) >> 4; + int b = (((scanline->buffer[x] & 0x7c00) >> 10) * fade) >> 4; + *BITMAP_ADDR32(bitmap, curline, x) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); + } } profiler_mark(PROFILER_END); @@ -1901,7 +1880,7 @@ VIDEO_UPDATE( snes ) int y; for (y = cliprect->min_y; y <= cliprect->max_y; y++) - snes_refresh_scanline(machine, bitmap, y); + snes_refresh_scanline(bitmap, y); return 0; } @@ -1910,7 +1889,7 @@ VIDEO_UPDATE( snes ) #ifdef SNES_DBG_video -static void snes_dbg_draw_maps(running_machine *machine, mame_bitmap *bitmap, UINT32 tmap, UINT8 bpl, UINT16 curline, UINT8 layer ) +static void snes_dbg_draw_maps(mame_bitmap *bitmap, UINT32 tmap, UINT8 bpl, UINT16 curline, UINT8 layer ) { UINT32 tile, addr = tmap; UINT16 ii, vflip, hflip, pal; @@ -1934,14 +1913,14 @@ static void snes_dbg_draw_maps(running_machine *machine, mame_bitmap *bitmap, UI switch( bpl ) { case 1: - snes_draw_tile_2(machine, MAINSCREEN, layer, snes_ppu.layer[layer].data + (tile << 4) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal ); + snes_draw_tile_2(MAINSCREEN, layer, snes_ppu.layer[layer].data + (tile << 4) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal ); break; case 2: pal <<= 2; - snes_draw_tile_4(machine, MAINSCREEN, layer, snes_ppu.layer[layer].data + (tile << 5) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal ); + snes_draw_tile_4(MAINSCREEN, layer, snes_ppu.layer[layer].data + (tile << 5) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal ); break; case 4: - snes_draw_tile_8(machine, MAINSCREEN, layer, snes_ppu.layer[layer].data + (tile << 6) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip ); + snes_draw_tile_8(MAINSCREEN, layer, snes_ppu.layer[layer].data + (tile << 6) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip ); break; } } @@ -1951,7 +1930,7 @@ static void snes_dbg_draw_maps(running_machine *machine, mame_bitmap *bitmap, UI //ui_draw_text( str, 0, 227 ); } -static void snes_dbg_draw_all_tiles(running_machine *machine, mame_bitmap *bitmap, UINT32 tileaddr, UINT8 bpl, UINT16 pal ) +static void snes_dbg_draw_all_tiles(mame_bitmap *bitmap, UINT32 tileaddr, UINT8 bpl, UINT16 pal ) { UINT16 ii, jj, kk; UINT32 addr = tileaddr; @@ -1970,13 +1949,13 @@ static void snes_dbg_draw_all_tiles(running_machine *machine, mame_bitmap *bitma switch( bpl ) { case 1: - snes_draw_tile_2(machine, MAINSCREEN, 0, addr, ii * 8, 255, 0, pal ); + snes_draw_tile_2(MAINSCREEN, 0, addr, ii * 8, 255, 0, pal ); break; case 2: - snes_draw_tile_4(machine, MAINSCREEN, 0, addr, ii * 8, 255, 0, pal ); + snes_draw_tile_4(MAINSCREEN, 0, addr, ii * 8, 255, 0, pal ); break; case 4: - snes_draw_tile_8(machine, MAINSCREEN, 0, addr, ii * 8, 255, 0 ); + snes_draw_tile_8(MAINSCREEN, 0, addr, ii * 8, 255, 0 ); break; } addr += (bpl * 16); @@ -1990,7 +1969,7 @@ static void snes_dbg_draw_all_tiles(running_machine *machine, mame_bitmap *bitma //ui_draw_text( str, 0, 227 ); } -static UINT8 snes_dbg_video(running_machine *machine, mame_bitmap *bitmap, UINT16 curline ) +static UINT8 snes_dbg_video(mame_bitmap *bitmap, UINT16 curline ) { UINT16 ii; @@ -2155,7 +2134,7 @@ static UINT8 snes_dbg_video(running_machine *machine, mame_bitmap *bitmap, UINT1 { scanlines[MAINSCREEN].buffer[ii] = 0; } - snes_dbg_draw_all_tiles(machine, bitmap, addr, dt, pal * 16 ); + snes_dbg_draw_all_tiles(bitmap, addr, dt, pal * 16 ); } return 1; } @@ -2179,7 +2158,7 @@ static UINT8 snes_dbg_video(running_machine *machine, mame_bitmap *bitmap, UINT1 /* Draw back colour */ for( ii = 0; ii < SNES_SCR_WIDTH; ii++ ) scanlines[MAINSCREEN].buffer[ii] = machine->pens[0]; - snes_dbg_draw_maps(machine, bitmap, tmaddr, dm, curline, tmbg ); + snes_dbg_draw_maps(bitmap, tmaddr, dm, curline, tmbg ); draw_scanline16( bitmap, 0, curline, SNES_SCR_WIDTH, scanlines[MAINSCREEN].buffer, machine->pens, 200 ); return 1; } @@ -2193,8 +2172,8 @@ static UINT8 snes_dbg_video(running_machine *machine, mame_bitmap *bitmap, UINT1 *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 2 ) = machine->pens[32767]; for( ii = 0; ii < 5; ii++ ) { - *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 19 + ii) = machine->remapped_colortable[0]; - *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 9 + ii) = machine->remapped_colortable[FIXED_COLOUR]; + *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 19 + ii) = snes_cgram[0]; + *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 9 + ii) = snes_cgram[FIXED_COLOUR]; } /* Draw window positions */ scanlines[MAINSCREEN].buffer[snes_ram[WH0]] = machine->pens[dbg_mode_colours[0]];