From 84a74dfcaa4123ee9a266584c0a93863e3b00aa5 Mon Sep 17 00:00:00 2001 From: Zsolt Vasvari Date: Mon, 7 Jan 2008 22:47:56 +0000 Subject: [PATCH] Draws background directly from memory avoiding having to decode the gfx repeadately. --- src/mame/drivers/exidy.c | 81 +++++------------ src/mame/includes/exidy.h | 5 +- src/mame/video/exidy.c | 178 +++++++++++++++++++++++--------------- 3 files changed, 133 insertions(+), 131 deletions(-) diff --git a/src/mame/drivers/exidy.c b/src/mame/drivers/exidy.c index f3c966508a0..64829b64ba6 100644 --- a/src/mame/drivers/exidy.c +++ b/src/mame/drivers/exidy.c @@ -189,7 +189,7 @@ static WRITE8_HANDLER( fax_bank_select_w ) static ADDRESS_MAP_START( common_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x03ff) AM_RAM - AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&videoram) AM_SIZE(&videoram_size) + AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&exidy_videoram) AM_RANGE(0x5000, 0x503f) AM_WRITE(exidy_sprite1_xpos_w) AM_RANGE(0x5040, 0x507f) AM_WRITE(exidy_sprite1_ypos_w) AM_RANGE(0x5080, 0x50bf) AM_WRITE(exidy_sprite2_xpos_w) @@ -746,28 +746,6 @@ INPUT_PORTS_END * *************************************/ -static const gfx_layout charlayout_1bpp = -{ - 8,8, - 256, - 1, - { 0 }, - { STEP8(0,1) }, - { STEP8(0,8) }, - 8*8 -}; - -static const gfx_layout charlayout_2bpp = -{ - 8,8, - 256, - 2, - { 0, 256*8*8 }, - { STEP8(0,1) }, - { STEP8(0,8) }, - 8*8 -}; - static const gfx_layout spritelayout = { 16,16, @@ -780,14 +758,7 @@ static const gfx_layout spritelayout = }; -static GFXDECODE_START( 1bpp ) - GFXDECODE_ENTRY( REGION_CPU1, 0x4800, charlayout_1bpp, 4, 4 ) /* the game dynamically modifies this */ - GFXDECODE_ENTRY( REGION_GFX1, 0x0000, spritelayout, 0, 2 ) -GFXDECODE_END - - -static GFXDECODE_START( 2bpp ) - GFXDECODE_ENTRY( REGION_CPU1, 0x6000, charlayout_2bpp, 4, 4 ) /* the game dynamically modifies this */ +static GFXDECODE_START( exidy ) GFXDECODE_ENTRY( REGION_GFX1, 0x0000, spritelayout, 0, 2 ) GFXDECODE_END @@ -843,8 +814,8 @@ static MACHINE_DRIVER_START( sidetrac ) MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) MDRV_SCREEN_RAW_PARAMS(EXIDY_PIXEL_CLOCK, EXIDY_HTOTAL, EXIDY_HBEND, EXIDY_HBSTART, EXIDY_VTOTAL, EXIDY_VBEND, EXIDY_VBSTART) - MDRV_GFXDECODE(1bpp) - MDRV_PALETTE_LENGTH(2*2 + 4*2) + MDRV_GFXDECODE(exidy) + MDRV_PALETTE_LENGTH(8) MDRV_VIDEO_START(exidy) MDRV_VIDEO_EOF(exidy) @@ -925,10 +896,6 @@ static MACHINE_DRIVER_START( pepper2 ) MDRV_IMPORT_FROM(venture) MDRV_CPU_MODIFY("main") MDRV_CPU_PROGRAM_MAP(common_map,pepper2_map) - - /* video hardware */ - MDRV_GFXDECODE(2bpp) - MDRV_PALETTE_LENGTH(2*2 + 4*4) MACHINE_DRIVER_END @@ -1357,17 +1324,10 @@ ROM_END * *************************************/ -static void exidy_common_init(UINT8 cmask, UINT8 cinvert) -{ - exidy_collision_mask = cmask; - exidy_collision_invert = cinvert; - targ_spec_flag = 0; -} - - static DRIVER_INIT( sidetrac ) { - exidy_common_init(0x00, 0x00); + exidy_video_config(0x00, 0x00, FALSE); + targ_spec_flag = 0; /* hard-coded palette controlled via 8x3 DIP switches on the board */ exidy_color_latch[2] = 0xf8; @@ -1378,20 +1338,20 @@ static DRIVER_INIT( sidetrac ) static DRIVER_INIT( targ ) { - exidy_common_init(0x00, 0x00); + exidy_video_config(0x00, 0x00, FALSE); + targ_spec_flag = 1; /* hard-coded palette controlled via 8x3 DIP switches on the board */ exidy_color_latch[2] = 0x5c; exidy_color_latch[1] = 0xee; exidy_color_latch[0] = 0x6b; - - targ_spec_flag = 1; } static DRIVER_INIT( spectar ) { - exidy_common_init(0x00, 0x00); + exidy_video_config(0x00, 0x00, FALSE); + targ_spec_flag = 0; /* hard-coded palette controlled via 8x3 DIP switches on the board */ exidy_color_latch[2] = 0x58; @@ -1401,7 +1361,8 @@ static DRIVER_INIT( spectar ) static DRIVER_INIT( rallys ) { - exidy_common_init(0x00, 0x00); + exidy_video_config(0x00, 0x00, FALSE); + targ_spec_flag = 0; /* hard-coded palette controlled via 8x3 DIP switches on the board */ exidy_color_latch[2] = 0x58; @@ -1417,7 +1378,8 @@ static DRIVER_INIT( rallys ) static DRIVER_INIT( phantoma ) { - exidy_common_init(0x00, 0x00); + exidy_video_config(0x00, 0x00, FALSE); + targ_spec_flag = 0; /* hard-coded palette controlled via 8x3 DIP switches on the board */ exidy_color_latch[2] = 0x58; @@ -1438,19 +1400,22 @@ static DRIVER_INIT( phantoma ) static DRIVER_INIT( mtrap ) { - exidy_common_init(0x14, 0x00); + exidy_video_config(0x14, 0x00, FALSE); + targ_spec_flag = 0; } static DRIVER_INIT( venture ) { - exidy_common_init(0x04, 0x04); + exidy_video_config(0x04, 0x04, FALSE); + targ_spec_flag = 0; } static DRIVER_INIT( teetert ) { - exidy_common_init(0x0c, 0x0c); + exidy_video_config(0x0c, 0x0c, FALSE); + targ_spec_flag = 0; /* special input handler for the dial */ memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x5101, 0x5101, 0, 0, teetert_input_r); @@ -1459,7 +1424,8 @@ static DRIVER_INIT( teetert ) static DRIVER_INIT( pepper2 ) { - exidy_common_init(0x14, 0x04); + exidy_video_config(0x14, 0x04, TRUE); + targ_spec_flag = 0; /* two 6116 character RAMs */ exidy_characterram = memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x6fff, 0, 0, MRA8_RAM); @@ -1471,7 +1437,8 @@ static DRIVER_INIT( pepper2 ) static DRIVER_INIT( fax ) { - exidy_common_init(0x04, 0x04); + exidy_video_config(0x04, 0x04, TRUE); + targ_spec_flag = 0; /* reset the ROM bank */ fax_bank_select_w(0,0); diff --git a/src/mame/includes/exidy.h b/src/mame/includes/exidy.h index e31532a9b9e..5015e763e8d 100644 --- a/src/mame/includes/exidy.h +++ b/src/mame/includes/exidy.h @@ -52,13 +52,12 @@ WRITE8_HANDLER( targ_sh_w ); /*----------- defined in video/exidy.c -----------*/ +extern UINT8 *exidy_videoram; extern UINT8 *exidy_characterram; -extern UINT8 exidy_collision_mask; -extern UINT8 exidy_collision_invert; - extern UINT8 *exidy_color_latch; +void exidy_video_config(UINT8 _collision_mask, UINT8 _collision_invert, int _is_2bpp); VIDEO_START( exidy ); VIDEO_EOF( exidy ); VIDEO_UPDATE( exidy ); diff --git a/src/mame/video/exidy.c b/src/mame/video/exidy.c index 0df13427d7e..95cde1ac4b0 100644 --- a/src/mame/video/exidy.c +++ b/src/mame/video/exidy.c @@ -7,12 +7,16 @@ #include "driver.h" #include "exidy.h" + +UINT8 *exidy_videoram; UINT8 *exidy_characterram; UINT8 *exidy_color_latch; -UINT8 exidy_collision_mask; -UINT8 exidy_collision_invert; +static UINT8 collision_mask; +static UINT8 collision_invert; +static int is_2bpp; +static mame_bitmap *background_bitmap; static mame_bitmap *motion_object_1_vid; static mame_bitmap *motion_object_2_vid; static mame_bitmap *motion_object_2_clip; @@ -30,6 +34,21 @@ static UINT8 sprite2_ypos; +/************************************* + * + * Video configuration + * + *************************************/ + +void exidy_video_config(UINT8 _collision_mask, UINT8 _collision_invert, int _is_2bpp) +{ + collision_mask = _collision_mask; + collision_invert = _collision_invert; + is_2bpp = _is_2bpp; +} + + + /************************************* * * Video startup @@ -38,8 +57,7 @@ static UINT8 sprite2_ypos; VIDEO_START( exidy ) { - video_start_generic(machine); - + background_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format); motion_object_1_vid = auto_bitmap_alloc(16, 16, machine->screen[0].format); motion_object_2_vid = auto_bitmap_alloc(16, 16, machine->screen[0].format); motion_object_2_clip = auto_bitmap_alloc(16, 16, machine->screen[0].format); @@ -55,8 +73,8 @@ VIDEO_START( exidy ) INLINE void latch_condition(int collision) { - collision ^= exidy_collision_invert; - int_condition = (readinputportbytag("INTSOURCE") & ~0x1c) | (collision & exidy_collision_mask); + collision ^= collision_invert; + int_condition = (readinputportbytag("INTSOURCE") & ~0x1c) | (collision & collision_mask); } @@ -99,9 +117,12 @@ READ8_HANDLER( exidy_interrupt_r ) * *************************************/ -INLINE void set_1_color(running_machine *machine, int index, int palette) +INLINE void set_1_color(running_machine *machine, int index, int which) { - palette_set_color_rgb(machine, index, pal1bit(exidy_color_latch[2] >> palette), pal1bit(exidy_color_latch[1] >> palette), pal1bit(exidy_color_latch[0] >> palette)); + palette_set_color_rgb(machine, index, + pal1bit(exidy_color_latch[2] >> which), + pal1bit(exidy_color_latch[1] >> which), + pal1bit(exidy_color_latch[0] >> which)); } static void set_colors(running_machine *machine) @@ -114,39 +135,11 @@ static void set_colors(running_machine *machine) set_1_color(machine, 2, 0); set_1_color(machine, 3, 6); - /* one-bit characters */ - if (machine->gfx[0]->color_granularity == 2) - { - set_1_color(machine, 4, 0); /* chars 0x00-0x3F */ - set_1_color(machine, 5, 4); - set_1_color(machine, 6, 0); /* chars 0x40-0x7F */ - set_1_color(machine, 7, 3); - set_1_color(machine, 8, 0); /* chars 0x80-0xBF */ - set_1_color(machine, 9, 2); - set_1_color(machine, 10, 0); /* chars 0xC0-0xFF */ - set_1_color(machine, 11, 1); - } - - /* two-bit characters */ - else - { - set_1_color(machine, 4, 0); /* chars 0x00-0x3F */ - set_1_color(machine, 5, 0); - set_1_color(machine, 6, 4); - set_1_color(machine, 7, 3); - set_1_color(machine, 8, 0); /* chars 0x40-0x7F */ - set_1_color(machine, 9, 0); - set_1_color(machine, 10, 4); - set_1_color(machine, 11, 3); - set_1_color(machine, 12, 0); /* chars 0x80-0xBF */ - set_1_color(machine, 13, 0); - set_1_color(machine, 14, 2); - set_1_color(machine, 15, 1); - set_1_color(machine, 16, 0); /* chars 0xC0-0xFF */ - set_1_color(machine, 17, 0); - set_1_color(machine, 18, 2); - set_1_color(machine, 19, 1); - } + /* characters */ + set_1_color(machine, 4, 4); + set_1_color(machine, 5, 3); + set_1_color(machine, 6, 2); + set_1_color(machine, 7, 1); } @@ -195,27 +188,70 @@ WRITE8_HANDLER( exidy_sprite_enable_w ) * *************************************/ -static void update_background(running_machine *machine) +static void draw_background(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect) { - int x, y, code, offs; + offs_t offs; - /* decode chars */ - const gfx_layout *gfx = machine->drv->gfxdecodeinfo[0].gfxlayout; + pen_t off_pen = 0; - for (code = 0; code < gfx->total; code++) - decodechar(machine->gfx[0], code, exidy_characterram, gfx); + for (offs = 0; offs < 0x400; offs++) + { + UINT8 cy; + pen_t on_pen_1, on_pen_2; - /* update the background */ - for (y = offs = 0; y < 32; y++) - for (x = 0; x < 32; x++, offs++) + UINT8 y = offs >> 5 << 3; + UINT8 code = exidy_videoram[offs]; + + if (is_2bpp) { - int color; - - code = videoram[offs]; - color = code >> 6; - - drawgfx(tmpbitmap, machine->gfx[0], code, color, 0, 0, x * 8, y * 8, NULL, TRANSPARENCY_NONE, 0); + on_pen_1 = 4 + ((code >> 6) & 0x02); + on_pen_2 = 5 + ((code >> 6) & 0x02); } + else + { + on_pen_1 = 4 + ((code >> 6) & 0x03); + on_pen_2 = off_pen; /* unused */ + } + + for (cy = 0; cy < 8; cy++) + { + int i; + UINT8 x = offs << 3; + + if (is_2bpp) + { + UINT8 data1 = exidy_characterram[0x000 | (code << 3) | cy]; + UINT8 data2 = exidy_characterram[0x800 | (code << 3) | cy]; + + for (i = 0; i < 8; i++) + { + if (data1 & 0x80) + *BITMAP_ADDR16(bitmap, y, x) = (data2 & 0x80) ? on_pen_2 : on_pen_1; + else + *BITMAP_ADDR16(bitmap, y, x) = off_pen; + + x = x + 1; + data1 = data1 << 1; + data2 = data2 << 1; + } + } + /* 1bpp */ + else + { + UINT8 data = exidy_characterram[(code << 3) | cy]; + + for (i = 0; i < 8; i++) + { + *BITMAP_ADDR16(bitmap, y, x) = (data & 0x80) ? on_pen_1 : off_pen; + + x = x + 1; + data = data << 1; + } + } + + y = y + 1; + } + } } @@ -251,9 +287,9 @@ static TIMER_CALLBACK( collision_irq_callback ) INLINE int sprite_1_enabled(void) { - /* if the exidy_collision_mask is 0x00, then we are on old hardware that always has */ + /* if the collision_mask is 0x00, then we are on old hardware that always has */ /* sprite 1 enabled regardless */ - return (!(sprite_enable & 0x80) || (sprite_enable & 0x10) || (exidy_collision_mask == 0x00)); + return (!(sprite_enable & 0x80) || (sprite_enable & 0x10) || (collision_mask == 0x00)); } VIDEO_EOF( exidy ) @@ -268,12 +304,12 @@ VIDEO_EOF( exidy ) int count = 0; /* if there is nothing to detect, bail */ - if (exidy_collision_mask == 0) + if (collision_mask == 0) return; /* update the background if necessary */ if (!update_complete) - update_background(machine); + draw_background(machine, background_bitmap, NULL); update_complete = 0; /* draw sprite 1 */ @@ -282,7 +318,7 @@ VIDEO_EOF( exidy ) { org_1_x = 236 - sprite1_xpos - 4; org_1_y = 244 - sprite1_ypos - 4; - drawgfx(motion_object_1_vid, machine->gfx[1], + drawgfx(motion_object_1_vid, machine->gfx[0], (spriteno & 0x0f) + 16 * enable_set_1, 0, 0, 0, 0, 0, &clip, TRANSPARENCY_PEN, 0); } @@ -291,7 +327,7 @@ VIDEO_EOF( exidy ) fillbitmap(motion_object_2_vid, 0xff, &clip); org_2_x = 236 - sprite2_xpos - 4; org_2_y = 244 - sprite2_ypos - 4; - drawgfx(motion_object_2_vid, machine->gfx[1], + drawgfx(motion_object_2_vid, machine->gfx[0], ((spriteno >> 4) & 0x0f) + 32 + 16 * enable_set_2, 0, 0, 0, 0, 0, &clip, TRANSPARENCY_PEN, 0); @@ -301,7 +337,7 @@ VIDEO_EOF( exidy ) { sx = org_2_x - org_1_x; sy = org_2_y - org_1_y; - drawgfx(motion_object_2_clip, machine->gfx[1], + drawgfx(motion_object_2_clip, machine->gfx[0], ((spriteno >> 4) & 0x0f) + 32 + 16 * enable_set_2, 0, 0, 0, sx, sy, &clip, TRANSPARENCY_PEN, 0); } @@ -315,7 +351,7 @@ VIDEO_EOF( exidy ) UINT8 collision_mask = 0; /* check for background collision (M1CHAR) */ - if (((*BITMAP_ADDR16(tmpbitmap, org_1_y + sy, org_1_x + sx) - 4) & bgmask) != 0) + if (((*BITMAP_ADDR16(background_bitmap, org_1_y + sy, org_1_x + sx) - 4) & bgmask) != 0) collision_mask |= 0x04; /* check for motion object collision (M1M2) */ @@ -323,14 +359,14 @@ VIDEO_EOF( exidy ) collision_mask |= 0x10; /* if we got one, trigger an interrupt */ - if ((collision_mask & exidy_collision_mask) && count++ < 128) + if ((collision_mask & collision_mask) && count++ < 128) timer_set(video_screen_get_time_until_pos(0, org_1_x + sx, org_1_y + sy), NULL, collision_mask, collision_irq_callback); } if (*BITMAP_ADDR16(motion_object_2_vid, sy, sx) != 0xff) { /* check for background collision (M2CHAR) */ - if (((*BITMAP_ADDR16(tmpbitmap, org_2_y + sy, org_2_x + sx) - 4) & bgmask) != 0) - if ((exidy_collision_mask & 0x08) && count++ < 128) + if (((*BITMAP_ADDR16(background_bitmap, org_2_y + sy, org_2_x + sx) - 4) & bgmask) != 0) + if ((collision_mask & 0x08) && count++ < 128) timer_set(video_screen_get_time_until_pos(0, org_2_x + sx, org_2_y + sy), NULL, 0x08, collision_irq_callback); } } @@ -353,8 +389,8 @@ VIDEO_UPDATE( exidy ) set_colors(machine); /* update the background and draw it */ - update_background(machine); - copybitmap(bitmap, tmpbitmap, 0, 0, 0, 0, cliprect, TRANSPARENCY_NONE, 0); + draw_background(machine, background_bitmap, NULL); + copybitmap(bitmap, background_bitmap, 0, 0, 0, 0, cliprect, TRANSPARENCY_NONE, 0); /* draw sprite 2 first */ enable_set_2 = ((sprite_enable & 0x40) != 0); @@ -362,7 +398,7 @@ VIDEO_UPDATE( exidy ) sx = 236 - sprite2_xpos - 4; sy = 244 - sprite2_ypos - 4; - drawgfx(bitmap, machine->gfx[1], + drawgfx(bitmap, machine->gfx[0], ((spriteno >> 4) & 0x0f) + 32 + 16 * enable_set_2, 1, 0, 0, sx, sy, cliprect, TRANSPARENCY_PEN, 0); @@ -376,7 +412,7 @@ VIDEO_UPDATE( exidy ) if (sy < 0) sy = 0; - drawgfx(bitmap, machine->gfx[1], + drawgfx(bitmap, machine->gfx[0], (spriteno & 0x0f) + 16 * enable_set_1, 0, 0, 0, sx, sy, cliprect, TRANSPARENCY_PEN, 0); }