diff options
Diffstat (limited to 'src/mame/video/taitosj.c')
-rw-r--r-- | src/mame/video/taitosj.c | 201 |
1 files changed, 92 insertions, 109 deletions
diff --git a/src/mame/video/taitosj.c b/src/mame/video/taitosj.c index c66aaca7130..0dac2bf2d8a 100644 --- a/src/mame/video/taitosj.c +++ b/src/mame/video/taitosj.c @@ -7,12 +7,14 @@ ***************************************************************************/ #include "driver.h" +#include "video/resnet.h" #define GLOBAL_FLIP_X (*taitosj_video_mode & 0x01) #define GLOBAL_FLIP_Y (*taitosj_video_mode & 0x02) #define SPRITE_RAM_PAGE_OFFSET ((*taitosj_video_mode & 0x04) ? 0x80 : 0x00) #define SPRITES_ON (*taitosj_video_mode & 0x80) +#define TRANSPARENT_PEN (0x40) UINT8 *taitosj_videoram_1; @@ -84,7 +86,7 @@ typedef void (*copy_layer_func_t)(running_machine *, mame_bitmap *, ***************************************************************************/ -static int draworder[32][4]; +static int draw_order[32][4]; /*************************************************************************** @@ -96,96 +98,58 @@ static int draworder[32][4]; The RAM is connected to the RGB output this way: - bit 0 -- inverter -- 220 ohm resistor -- RED + bit 0 -- inverter -- 270 ohm resistor -- RED bit 7 -- inverter -- 470 ohm resistor -- RED -- inverter -- 1 kohm resistor -- RED - -- inverter -- 220 ohm resistor -- GREEN + -- inverter -- 270 ohm resistor -- GREEN -- inverter -- 470 ohm resistor -- GREEN -- inverter -- 1 kohm resistor -- GREEN - -- inverter -- 220 ohm resistor -- BLUE + -- inverter -- 270 ohm resistor -- BLUE -- inverter -- 470 ohm resistor -- BLUE bit 0 -- inverter -- 1 kohm resistor -- BLUE ***************************************************************************/ -PALETTE_INIT( taitosj ) +static void set_pens(running_machine *machine) { + static const int resistances[3] = { 1000, 470, 270 }; + double rweights[3], gweights[3], bweights[3]; int i; - #define COLOR(gfxn,offs) (colortable[machine->config->gfxdecodeinfo[gfxn].color_codes_start + offs]) - - /* all gfx elements use the same palette */ - for (i = 0 ;i < 64; i++) - { - /* we create both a "normal" lookup table and one where pen 0 is */ - /* always mapped to color 0. This is needed for transparency. */ - - COLOR(0, i) = i; - - if ((i % 8) == 0) - COLOR(0, i + 64) = 0; - else - COLOR(0, i + 64) = i; - } - - /* do a simple conversion of the PROM into layer priority order. Note that */ - /* this is a simplification, which assumes the PROM encodes a sensible priority */ - /* scheme. */ - color_prom = memory_region(REGION_PROMS); - - for (i = 0; i < 32; i++) - { - int j, mask; - - mask = 0; /* start with all four layers active, so we'll get the highest */ - /* priority one in the first loop */ - - for (j = 3; j >= 0; j--) - { - int data; - - data = color_prom[0x10 * (i & 0x0f) + mask]; - if (i & 0x10) data >>= 2; - data &= 0x03; - mask |= (1 << data); /* in next loop, we'll see which of the remaining */ - /* layers has top priority when this one is transparent */ - draworder[i][j] = data; - } - } -} + /* compute the color output resistor weights */ + compute_resistor_weights(0, 255, -1.0, + 3, resistances, rweights, 0, 0, + 3, resistances, gweights, 0, 0, + 3, resistances, bweights, 0, 0); -static void set_colors(running_machine *machine) -{ - offs_t offs; - - for (offs = 0; offs < 0x40; offs++) + for (i = 0; i < 0x40; i++) { - int bit0,bit1,bit2; - int r,g,b,val; + int bit0, bit1, bit2; + int r, g, b, val; /* red component */ - val = taitosj_paletteram[(offs << 1) | 0x01]; + val = taitosj_paletteram[(i << 1) | 0x01]; bit0 = (~val >> 6) & 0x01; bit1 = (~val >> 7) & 0x01; - val = taitosj_paletteram[(offs << 1) | 0x00]; + val = taitosj_paletteram[(i << 1) | 0x00]; bit2 = (~val >> 0) & 0x01; - r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + r = combine_3_weights(rweights, bit0, bit1, bit2); /* green component */ - val = taitosj_paletteram[(offs << 1) | 0x01]; + val = taitosj_paletteram[(i << 1) | 0x01]; bit0 = (~val >> 3) & 0x01; bit1 = (~val >> 4) & 0x01; bit2 = (~val >> 5) & 0x01; - g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + g = combine_3_weights(gweights, bit0, bit1, bit2); /* blue component */ - val = taitosj_paletteram[(offs << 1) | 0x01]; + val = taitosj_paletteram[(i << 1) | 0x01]; bit0 = (~val >> 0) & 0x01; bit1 = (~val >> 1) & 0x01; bit2 = (~val >> 2) & 0x01; - b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + b = combine_3_weights(bweights, bit0, bit1, bit2); - palette_set_color(machine, offs, MAKE_RGB(r,g,b)); + palette_set_color(machine, i, MAKE_RGB(r, g, b)); } } @@ -203,6 +167,38 @@ static void taitosj_postload(void) Start the video hardware emulation. ***************************************************************************/ + +static void compute_draw_order(void) +{ + int i; + + /* do a simple conversion of the PROM into layer priority order. Note that */ + /* this is a simplification, which assumes the PROM encodes a sensible priority */ + /* scheme. */ + for (i = 0; i < 32; i++) + { + int j; + int mask = 0; /* start with all four layers active, so we'll get the highest */ + /* priority one in the first loop */ + for (j = 3; j >= 0; j--) + { + UINT8 *color_prom = memory_region(REGION_PROMS); + + int data = color_prom[0x10 * (i & 0x0f) + mask] & 0x0f; + + if (i & 0x10) + data = data >> 2; + else + data = data & 0x03; + + mask |= (1 << data); /* in next loop, we'll see which of the remaining */ + /* layers has top priority when this one is transparent */ + draw_order[i][j] = data; + } + } +} + + VIDEO_START( taitosj ) { int i; @@ -223,6 +219,8 @@ VIDEO_START( taitosj ) memset(dirtysprite1, 1, sizeof(dirtysprite1)); memset(dirtysprite2, 1, sizeof(dirtysprite2)); + compute_draw_order(); + state_save_register_func_postload(taitosj_postload); } @@ -339,33 +337,29 @@ static int check_sprite_sprite_bitpattern(running_machine *machine, } /* draw the sprites into seperate bitmaps and check overlapping region */ + fillbitmap(sprite_layer_collbitmap1, TRANSPARENT_PEN, NULL); drawgfx(sprite_sprite_collbitmap1, get_sprite_gfx_element(machine, which1), taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 3] & 0x3f, 0, taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x01, taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x02, sx1, sy1, - 0, TRANSPARENCY_NONE, 0); + 0, TRANSPARENCY_PEN, 0); + fillbitmap(sprite_sprite_collbitmap2, TRANSPARENT_PEN, NULL); drawgfx(sprite_sprite_collbitmap2, get_sprite_gfx_element(machine, which2), taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 3] & 0x3f, 0, taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x01, taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x02, sx2, sy2, - 0, TRANSPARENCY_NONE, 0); + 0, TRANSPARENCY_PEN, 0); for (y = miny; y < maxy; y++) - { for (x = minx; x < maxx; x++) - { - if ((*BITMAP_ADDR16(sprite_sprite_collbitmap1, y, x) != machine->pens[0]) && - (*BITMAP_ADDR16(sprite_sprite_collbitmap2, y, x) != machine->pens[0])) - { + if ((*BITMAP_ADDR16(sprite_sprite_collbitmap1, y, x) != TRANSPARENT_PEN) && + (*BITMAP_ADDR16(sprite_sprite_collbitmap2, y, x) != TRANSPARENT_PEN)) return 1; /* collided */ - } - } - } return 0; } @@ -480,7 +474,7 @@ static void calculate_sprite_areas(running_machine *machine, int *sprites_on, re static int check_sprite_layer_bitpattern(running_machine *machine, int which, rectangle *sprite_areas) { - int y; + int y, x; offs_t offs = which * 4; int result = 0; /* no collisions */ @@ -497,32 +491,27 @@ static int check_sprite_layer_bitpattern(running_machine *machine, int which, re int flip_y = (taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02) ^ GLOBAL_FLIP_Y; /* draw sprite into a bitmap and check if layers collide */ + fillbitmap(sprite_layer_collbitmap1, TRANSPARENT_PEN, NULL); drawgfx(sprite_layer_collbitmap1, get_sprite_gfx_element(machine, which), taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f, 0, flip_x, flip_y, 0,0, - 0,TRANSPARENCY_NONE,0); + 0,TRANSPARENCY_PEN,0); for (y = miny; y < maxy; y++) - { - int x; - for (x = minx; x < maxx; x++) - { - if (*BITMAP_ADDR16(sprite_layer_collbitmap1, y - miny, x - minx) != machine->pens[0]) /* is there anything to check for ? */ + if (*BITMAP_ADDR16(sprite_layer_collbitmap1, y - miny, x - minx) != TRANSPARENT_PEN) /* is there anything to check for ? */ { - if (check_layer_1 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[0], y, x) != machine->pens[0])) + if (check_layer_1 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[0], y, x) != TRANSPARENT_PEN)) result |= 0x01; /* collided with layer 1 */ - if (check_layer_2 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[1], y, x) != machine->pens[0])) + if (check_layer_2 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[1], y, x) != TRANSPARENT_PEN)) result |= 0x02; /* collided with layer 2 */ - if (check_layer_3 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[2], y, x) != machine->pens[0])) + if (check_layer_3 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[2], y, x) != TRANSPARENT_PEN)) result |= 0x04; /* collided with layer 3 */ } - } - } return result; } @@ -588,6 +577,10 @@ static void draw_layers(running_machine *machine) { offs_t offs; + fillbitmap(taitosj_layer_bitmap[0], TRANSPARENT_PEN, NULL); + fillbitmap(taitosj_layer_bitmap[1], TRANSPARENT_PEN, NULL); + fillbitmap(taitosj_layer_bitmap[2], TRANSPARENT_PEN, NULL); + for (offs = 0; offs < 0x0400; offs++) { int sx = offs % 32; @@ -598,24 +591,24 @@ static void draw_layers(running_machine *machine) drawgfx(taitosj_layer_bitmap[0],machine->gfx[taitosj_colorbank[0] & 0x08 ? 2 : 0], taitosj_videoram_1[offs], - (taitosj_colorbank[0] & 0x07) + 8, /* use transparent pen 0 */ + taitosj_colorbank[0] & 0x07, GLOBAL_FLIP_X,GLOBAL_FLIP_Y, 8*sx,8*sy, - 0,TRANSPARENCY_NONE,0); + 0,TRANSPARENCY_PEN,0); drawgfx(taitosj_layer_bitmap[1],machine->gfx[taitosj_colorbank[0] & 0x80 ? 2 : 0], taitosj_videoram_2[offs], - ((taitosj_colorbank[0] >> 4) & 0x07) + 8, /* use transparent pen 0 */ + (taitosj_colorbank[0] >> 4) & 0x07, GLOBAL_FLIP_X,GLOBAL_FLIP_Y, 8*sx,8*sy, - 0,TRANSPARENCY_NONE,0); + 0,TRANSPARENCY_PEN,0); drawgfx(taitosj_layer_bitmap[2],machine->gfx[taitosj_colorbank[1] & 0x08 ? 2 : 0], taitosj_videoram_3[offs], - (taitosj_colorbank[1] & 0x07) + 8, /* use transparent pen 0 */ + taitosj_colorbank[1] & 0x07, GLOBAL_FLIP_X,GLOBAL_FLIP_Y, 8*sx,8*sy, - 0,TRANSPARENCY_NONE,0); + 0,TRANSPARENCY_PEN,0); } } @@ -704,17 +697,13 @@ static void taitosj_copy_layer(running_machine *machine, mame_bitmap *bitmap, co scrollx = -(scrollx & 0xf8) + ((scrollx + fudge1[which]) & 7) + fudge2[which]; if (GLOBAL_FLIP_Y) - { for (i = 0;i < 32;i++) scrolly[31 - i] = taitosj_colscrolly[32 * which + i] + taitosj_scroll[2 * which + 1]; - } else - { for (i = 0;i < 32;i++) scrolly[i] = -taitosj_colscrolly[32 * which + i] - taitosj_scroll[2 * which + 1]; - } - copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 1, &scrollx, 32, scrolly, cliprect, machine->pens[0]); + copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 1, &scrollx, 32, scrolly, cliprect, TRANSPARENT_PEN); /* store parts covered with sprites for sprites/layers collision detection */ for (i = 0; i < 0x20; i++) @@ -736,29 +725,23 @@ static void kikstart_copy_layer(running_machine *machine, mame_bitmap *bitmap, c int i, scrolly, scrollx[32 * 8]; for (i = 1; i < 32*8; i++) /* 1-255 ! */ - { if (GLOBAL_FLIP_Y) - { switch (which) { - case 0: scrollx[32 * 8 - i] = 0 ;break; - case 1: scrollx[32 * 8 - i] = kikstart_scrollram[i] + ((taitosj_scroll[2 * which] + 0x0a) & 0xff);break; - case 2: scrollx[32 * 8 - i] = kikstart_scrollram[0x100 + i] + ((taitosj_scroll[2 * which] + 0xc) & 0xff);break; + case 0: scrollx[32 * 8 - i] = 0 ;break; + case 1: scrollx[32 * 8 - i] = kikstart_scrollram[i] + ((taitosj_scroll[2 * which] + 0x0a) & 0xff);break; + case 2: scrollx[32 * 8 - i] = kikstart_scrollram[0x100 + i] + ((taitosj_scroll[2 * which] + 0xc) & 0xff);break; } - } else - { switch (which) { - case 0: scrollx[i] = 0 ;break; - case 1: scrollx[i] = 0xff - kikstart_scrollram[i - 1] - ((taitosj_scroll[2 * which] - 0x10) & 0xff);break; - case 2: scrollx[i] = 0xff - kikstart_scrollram[0x100 + i - 1] - ((taitosj_scroll[2 * which] - 0x12) & 0xff);break; + case 0: scrollx[i] = 0 ;break; + case 1: scrollx[i] = 0xff - kikstart_scrollram[i - 1] - ((taitosj_scroll[2 * which] - 0x10) & 0xff);break; + case 2: scrollx[i] = 0xff - kikstart_scrollram[0x100 + i - 1] - ((taitosj_scroll[2 * which] - 0x12) & 0xff);break; } - } - } scrolly = taitosj_scroll[2 * which + 1]; /* always 0 */ - copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, cliprect, machine->pens[0]); + copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, cliprect, TRANSPARENT_PEN); /* store parts covered with sprites for sprites/layers collision detection */ for (i = 0; i < 0x20; i++) @@ -792,7 +775,7 @@ static void copy_layers(running_machine *machine, mame_bitmap *bitmap, const rec for (i = 0; i < 4; i++) { - int which = draworder[*taitosj_video_priority & 0x1f][i]; + int which = draw_order[*taitosj_video_priority & 0x1f][i]; copy_layer(machine, bitmap, cliprect, copy_layer_func, which, sprites_on, sprite_areas); } @@ -815,7 +798,7 @@ static int video_update_common(running_machine *machine, mame_bitmap *bitmap, int sprites_on[0x20]; /* 1 if sprite is active */ rectangle sprite_areas[0x20]; /* areas on bitmap (sprite locations) */ - set_colors(machine); + set_pens(machine); decode_modified(machine); |