From 2e595362d8f79e3182e5846434459f2301b152d8 Mon Sep 17 00:00:00 2001 From: Zsolt Vasvari Date: Thu, 21 Feb 2008 09:12:53 +0000 Subject: [PATCH] - Some more machine->pen lookup removal - Changed Beathead driver to use partial updates instead of caching scanline level information --- src/mame/drivers/beathead.c | 2 +- src/mame/includes/beathead.h | 2 -- src/mame/video/aliens.c | 2 +- src/mame/video/alpha68k.c | 10 +++---- src/mame/video/ambush.c | 2 +- src/mame/video/asterix.c | 2 +- src/mame/video/asuka.c | 4 +-- src/mame/video/battlane.c | 8 ++--- src/mame/video/battlera.c | 2 +- src/mame/video/bbusters.c | 4 +-- src/mame/video/beathead.c | 58 ++++++++++++------------------------ src/mame/video/exerion.c | 2 +- src/mame/video/magmax.c | 2 +- src/mame/video/polepos.c | 2 +- src/mame/video/toypop.c | 2 +- 15 files changed, 39 insertions(+), 65 deletions(-) diff --git a/src/mame/drivers/beathead.c b/src/mame/drivers/beathead.c index 8710a9ce288..e9c4dd9439f 100644 --- a/src/mame/drivers/beathead.c +++ b/src/mame/drivers/beathead.c @@ -141,7 +141,7 @@ static TIMER_CALLBACK( scanline_callback ) int scanline = param; /* update the video */ - beathead_scanline_update(scanline); + video_screen_update_now(0); /* on scanline zero, clear any halt condition */ if (scanline == 0) diff --git a/src/mame/includes/beathead.h b/src/mame/includes/beathead.h index 8418937658e..134e9566ab3 100644 --- a/src/mame/includes/beathead.h +++ b/src/mame/includes/beathead.h @@ -12,8 +12,6 @@ extern UINT32 * beathead_palette_select; VIDEO_START( beathead ); VIDEO_UPDATE( beathead ); -void beathead_scanline_update(int scanline); - WRITE32_HANDLER( beathead_vram_transparent_w ); WRITE32_HANDLER( beathead_vram_bulk_w ); WRITE32_HANDLER( beathead_vram_latch_w ); diff --git a/src/mame/video/aliens.c b/src/mame/video/aliens.c index f6719868488..9552e914b2d 100644 --- a/src/mame/video/aliens.c +++ b/src/mame/video/aliens.c @@ -76,7 +76,7 @@ VIDEO_UPDATE( aliens ) K052109_tilemap_update(); fillbitmap(priority_bitmap,0,cliprect); - fillbitmap(bitmap,machine->pens[layer_colorbase[1] * 16],cliprect); + fillbitmap(bitmap,layer_colorbase[1] * 16,cliprect); tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,1); tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,2); tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,4); diff --git a/src/mame/video/alpha68k.c b/src/mame/video/alpha68k.c index 73ccd0a4f19..8a8c2815dea 100644 --- a/src/mame/video/alpha68k.c +++ b/src/mame/video/alpha68k.c @@ -133,7 +133,7 @@ VIDEO_UPDATE( alpha68k_II ) last_bank=bank_base; tilemap_set_flip(ALL_TILEMAPS,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - fillbitmap(bitmap,machine->pens[2047],cliprect); + fillbitmap(bitmap,2047,cliprect); //AT draw_sprites(machine, bitmap,cliprect,0,0x07c0,0x0800); draw_sprites(machine, bitmap,cliprect,1,0x0000,0x0800); @@ -272,7 +272,7 @@ VIDEO_UPDATE( alpha68k_V ) last_bank=bank_base; tilemap_set_flip(ALL_TILEMAPS,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - fillbitmap(bitmap,machine->pens[4095],cliprect); + fillbitmap(bitmap,4095,cliprect); /* This appears to be correct priority */ if (alpha68k_microcontroller_id == 0x8814) /* Sky Adventure */ @@ -308,7 +308,7 @@ VIDEO_UPDATE( alpha68k_V_sb ) last_bank=bank_base; tilemap_set_flip(ALL_TILEMAPS,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - fillbitmap(bitmap,machine->pens[4095],cliprect); + fillbitmap(bitmap,4095,cliprect); /* This appears to be correct priority */ draw_sprites_V(machine,bitmap,cliprect,0,0x07c0,0x0800,0x4000,0x8000,0x3fff); @@ -480,7 +480,7 @@ static void kyros_draw_sprites(running_machine *machine, mame_bitmap *bitmap, co VIDEO_UPDATE( kyros ) { colortable_entry_set_value(machine->colortable, 0x100, *videoram16 & 0xff); - fillbitmap(bitmap, machine->pens[0x100], cliprect); //AT + fillbitmap(bitmap, 0x100, cliprect); //AT kyros_draw_sprites(machine, bitmap,cliprect,2,0x0800); kyros_draw_sprites(machine, bitmap,cliprect,3,0x0c00); @@ -538,7 +538,7 @@ static void sstingry_draw_sprites(running_machine *machine, mame_bitmap *bitmap, VIDEO_UPDATE( sstingry ) { colortable_entry_set_value(machine->colortable, 0x100, *videoram16 & 0xff); - fillbitmap(bitmap, machine->pens[0x100], cliprect); //AT + fillbitmap(bitmap, 0x100, cliprect); //AT sstingry_draw_sprites(machine, bitmap,cliprect,2,0x0800); sstingry_draw_sprites(machine, bitmap,cliprect,3,0x0c00); diff --git a/src/mame/video/ambush.c b/src/mame/video/ambush.c index d7918df7775..262b2119832 100644 --- a/src/mame/video/ambush.c +++ b/src/mame/video/ambush.c @@ -95,7 +95,7 @@ VIDEO_UPDATE( ambush ) int offs; - fillbitmap(bitmap,machine->pens[0],cliprect); + fillbitmap(bitmap,0,cliprect); /* Draw the background priority characters */ diff --git a/src/mame/video/asterix.c b/src/mame/video/asterix.c index 0275cbde41e..afde73862ec 100644 --- a/src/mame/video/asterix.c +++ b/src/mame/video/asterix.c @@ -117,7 +117,7 @@ VIDEO_UPDATE( asterix ) sortlayers(layer, layerpri); fillbitmap(priority_bitmap, 0, cliprect); - fillbitmap(bitmap, machine->pens[0], cliprect); + fillbitmap(bitmap, 0, cliprect); K056832_tilemap_draw(machine, bitmap, cliprect, layer[0], 0, 1); K056832_tilemap_draw(machine, bitmap, cliprect, layer[1], 0, 2); diff --git a/src/mame/video/asuka.c b/src/mame/video/asuka.c index dff8d0a7d70..cbd5fdae5c0 100644 --- a/src/mame/video/asuka.c +++ b/src/mame/video/asuka.c @@ -56,7 +56,7 @@ VIDEO_UPDATE( asuka ) fillbitmap(priority_bitmap,0,cliprect); /* Ensure screen blanked even when bottom layer not drawn due to disable bit */ - fillbitmap(bitmap, machine->pens[0], cliprect); + fillbitmap(bitmap, 0, cliprect); TC0100SCN_tilemap_draw(machine,bitmap,cliprect,0,layer[0],TILEMAP_DRAW_OPAQUE,1); TC0100SCN_tilemap_draw(machine,bitmap,cliprect,0,layer[1],0,2); @@ -81,7 +81,7 @@ VIDEO_UPDATE( bonzeadv ) fillbitmap(priority_bitmap,0,cliprect); /* Ensure screen blanked even when bottom layer not drawn due to disable bit */ - fillbitmap(bitmap, machine->pens[0], cliprect); + fillbitmap(bitmap, 0, cliprect); TC0100SCN_tilemap_draw(machine,bitmap,cliprect,0,layer[0],TILEMAP_DRAW_OPAQUE,1); TC0100SCN_tilemap_draw(machine,bitmap,cliprect,0,layer[1],0,2); diff --git a/src/mame/video/battlane.c b/src/mame/video/battlane.c index 2588d3d470b..f437d2f3523 100644 --- a/src/mame/video/battlane.c +++ b/src/mame/video/battlane.c @@ -228,13 +228,9 @@ static void draw_fg_bitmap(running_machine *machine, mame_bitmap *bitmap ) if (data) { if (flip_screen) - { - *BITMAP_ADDR16(bitmap, 255 - y, 255 - x) = machine->pens[data]; - } + *BITMAP_ADDR16(bitmap, 255 - y, 255 - x) = data; else - { - *BITMAP_ADDR16(bitmap, y, x) = machine->pens[data]; - } + *BITMAP_ADDR16(bitmap, y, x) = data; } } } diff --git a/src/mame/video/battlera.c b/src/mame/video/battlera.c index 88d2bda5470..6e5d248a57f 100644 --- a/src/mame/video/battlera.c +++ b/src/mame/video/battlera.c @@ -373,7 +373,7 @@ static void screenrefresh(running_machine *machine, mame_bitmap *bitmap,const re if (sb_enable) draw_sprites(machine,bitmap,clip,0); /* Render background over sprites */ - copyscrollbitmap_trans(bitmap,front_bitmap,1,&scrollx,1,&scrolly,clip,machine->pens[256]); + copyscrollbitmap_trans(bitmap,front_bitmap,1,&scrollx,1,&scrolly,clip,256); /* Render high priority sprites, if enabled */ if (sb_enable) draw_sprites(machine,bitmap,clip,1); diff --git a/src/mame/video/bbusters.c b/src/mame/video/bbusters.c index 8c28d836c93..ff9839ee1b0 100644 --- a/src/mame/video/bbusters.c +++ b/src/mame/video/bbusters.c @@ -148,7 +148,7 @@ INLINE const UINT8 *get_source_ptr(running_machine *machine, UINT32 sprite, int static void bbusters_draw_block(running_machine *machine, mame_bitmap *dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block) { - const pen_t *pal = &machine->pens[machine->gfx[bank]->color_base + machine->gfx[bank]->color_granularity * (color % machine->gfx[bank]->total_colors)]; + pen_t pen_base = machine->gfx[bank]->color_base + machine->gfx[bank]->color_granularity * (color % machine->gfx[bank]->total_colors); UINT32 xinc=(scale_line_count * 0x10000 ) / size; UINT8 pixel; int x_index; @@ -176,7 +176,7 @@ static void bbusters_draw_block(running_machine *machine, mame_bitmap *dest,int pixel=*srcptr++; if (x+(x_index>>16)>=0 && x+(x_index>>16)<256 && pixel!=15) - destline[x+(x_index>>16)]=pal[pixel]; + destline[x+(x_index>>16)]= pen_base + pixel; if (flipx) x_index-=xinc; diff --git a/src/mame/video/beathead.c b/src/mame/video/beathead.c index ca5ba47073b..d4691a2cadf 100644 --- a/src/mame/video/beathead.c +++ b/src/mame/video/beathead.c @@ -27,10 +27,6 @@ UINT32 * beathead_palette_select; * *************************************/ -static offs_t scanline_offset[240]; -static UINT8 scanline_palette[240]; - -static int current_scanline; static UINT32 finescroll; static offs_t vram_latch_offset; @@ -115,10 +111,10 @@ WRITE32_HANDLER( beathead_finescroll_w ) UINT32 oldword = finescroll; UINT32 newword = COMBINE_DATA(&finescroll); - /* if VBLANK is going off on a non-zero scanline, suspend time */ - if ((oldword & 8) && !(newword & 8) && current_scanline != 0) + /* if VBLANK is going off on a scanline other than the last, suspend time */ + if ((oldword & 8) && !(newword & 8) && video_screen_get_vpos(0) != 261) { - logerror("Suspending time! (scanline = %d)\n", current_scanline); + logerror("Suspending time! (scanline = %d)\n", video_screen_get_vpos(0)); cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, ASSERT_LINE); } } @@ -178,29 +174,6 @@ WRITE32_HANDLER( beathead_hsync_ram_w ) -/************************************* - * - * Scanline updater - * - *************************************/ - -void beathead_scanline_update(int scanline) -{ - /* remember the current scanline */ - current_scanline = scanline; - - /* grab the latch for the previous scanline */ - scanline--; - if (scanline < 0 || scanline >= 240) - return; - - /* cache the offset and palette for this scanline */ - scanline_offset[scanline] = (finescroll & 8) ? ~0 : vram_latch_offset + (finescroll & 3); - scanline_palette[scanline] = *beathead_palette_select & 0x7f; -} - - - /************************************* * * Main screen refresher @@ -214,20 +187,27 @@ VIDEO_UPDATE( beathead ) /* generate the final screen */ for (y = cliprect->min_y; y <= cliprect->max_y; y++) { - offs_t src = scanline_offset[y] + cliprect->min_x; - UINT8 scanline[336]; + pen_t pen_base = (*beathead_palette_select & 0x7f) * 256; + UINT16 scanline[336]; - /* unswizzle the scanline first */ - if (scanline_offset[y] != ~0) - { + /* blanking */ + if (finescroll & 8) for (x = cliprect->min_x; x <= cliprect->max_x; x++) - scanline[x] = ((UINT8 *)videoram32)[BYTE4_XOR_LE(src++)]; - } + scanline[x] = pen_base; + + /* non-blanking */ else - memset(scanline, 0, sizeof(scanline)); + { + offs_t scanline_offset = vram_latch_offset + (finescroll & 3); + offs_t src = scanline_offset + cliprect->min_x; + + /* unswizzle the scanline first */ + for (x = cliprect->min_x; x <= cliprect->max_x; x++) + scanline[x] = pen_base | ((UINT8 *)videoram32)[BYTE4_XOR_LE(src++)]; + } /* then draw it */ - draw_scanline8(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], &machine->pens[scanline_palette[y] * 256], -1); + draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL, -1); } return 0; } diff --git a/src/mame/video/exerion.c b/src/mame/video/exerion.c index cac795fff2b..d1fd4ae86a6 100644 --- a/src/mame/video/exerion.c +++ b/src/mame/video/exerion.c @@ -261,7 +261,7 @@ static void draw_background(mame_bitmap *bitmap, const rectangle *cliprect) int stop3 = background_latches[11] >> 4; UINT8 *mixer = &background_mixer[(background_latches[12] << 4) & 0xf0]; UINT16 scanline[VISIBLE_X_MAX]; - int pen_base = 0x200 + ((background_latches[12] >> 4) << 4); + pen_t pen_base = 0x200 + ((background_latches[12] >> 4) << 4); /* the cocktail flip flag controls whether we count up or down in X */ if (!exerion_cocktail_flip) diff --git a/src/mame/video/magmax.c b/src/mame/video/magmax.c index 5ccc30a322b..d9a9b465515 100644 --- a/src/mame/video/magmax.c +++ b/src/mame/video/magmax.c @@ -119,7 +119,7 @@ VIDEO_UPDATE( magmax ) UINT32 rom15F_addr = (((scroll_v + v) & 0x07)<<2) + (map_v_scr_100<<5); UINT32 map_v_scr_1fe_6 =((scroll_v + v) & 0x1fe)<<6; - int pen_base = 0x110 + 0x20 + (map_v_scr_100>>1); + pen_t pen_base = 0x110 + 0x20 + (map_v_scr_100>>1); for (h = 0; h < 0x100; h++) { diff --git a/src/mame/video/polepos.c b/src/mame/video/polepos.c index bd615732d7f..914a38a5803 100644 --- a/src/mame/video/polepos.c +++ b/src/mame/video/polepos.c @@ -364,7 +364,7 @@ static void draw_road(mame_bitmap *bitmap) int xoffs, yoffs, xscroll, roadpal; UINT16 scanline[256 + 8]; UINT16 *dest = scanline; - int pen_base; + pen_t pen_base; /* first add the vertical position modifier and the vertical scroll */ yoffs = ((polepos_vertical_position_modifier[y] + road16_vscroll) >> 3) & 0x1ff; diff --git a/src/mame/video/toypop.c b/src/mame/video/toypop.c index 025934ebe8e..dd34a37bdfe 100644 --- a/src/mame/video/toypop.c +++ b/src/mame/video/toypop.c @@ -178,7 +178,7 @@ static void draw_background(mame_bitmap *bitmap) { int offs, x, y; UINT16 scanline[288]; - int pen_base = 0x300 + 0x10*palettebank; + pen_t pen_base = 0x300 + 0x10*palettebank; // copy the background image from RAM (0x190200-0x19FDFF) to bitmap if (bitmapflip)