From 3d5ae65fd7c5be1cae839c99a61be8cf66b4005d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Banaan=20Ananas?= Date: Tue, 8 Mar 2011 19:51:27 +0000 Subject: [PATCH] - use 4 bit clut instead of 3 bit - calculate palette with resnet info from Popper (same year, same company, very similar hardware) - make bgcolor emulation more logical - small cleanups --- src/mame/drivers/carjmbre.c | 43 +++++------ src/mame/includes/carjmbre.h | 1 + src/mame/video/carjmbre.c | 143 +++++++++++++++++++---------------- 3 files changed, 97 insertions(+), 90 deletions(-) diff --git a/src/mame/drivers/carjmbre.c b/src/mame/drivers/carjmbre.c index 97ae97663d0..5cb85b158a4 100644 --- a/src/mame/drivers/carjmbre.c +++ b/src/mame/drivers/carjmbre.c @@ -1,7 +1,7 @@ /*************************************************************************** Car Jamboree - Omori Electric CAD (OEC) 1981 + Omori Electric CAD (OEC) 1983 c14 c.d19 c13 c.d18 c10 @@ -33,7 +33,7 @@ Notes: just before exploding, animals displaying as the wrong sprite for one frame when entering the arena -- colours are wrong, sprites and characters only using one of the proms +- colours look wrong, maybe address bitswap? - background colour calculation is a guess @@ -53,27 +53,22 @@ Notes: static ADDRESS_MAP_START( carjmbre_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x87ff) AM_RAM - AM_RANGE(0x8800, 0x8800) AM_READNOP //?? possibly watchdog +// AM_RANGE(0x8800, 0x8800) AM_READNOP // watchdog? AM_RANGE(0x8803, 0x8803) AM_WRITE(interrupt_enable_w) - AM_RANGE(0x8805, 0x8806) AM_WRITE(carjmbre_bgcolor_w) //guess + AM_RANGE(0x8805, 0x8805) AM_WRITE(carjmbre_bgcolor_w) // guessed + AM_RANGE(0x8806, 0x8806) AM_WRITE(carjmbre_8806_w) // video related? AM_RANGE(0x8807, 0x8807) AM_WRITE(carjmbre_flipscreen_w) - AM_RANGE(0x8fc1, 0x8fc1) AM_WRITENOP //overrun during initial screen clear - AM_RANGE(0x8fe1, 0x8fe1) AM_WRITENOP //overrun during initial screen clear +// AM_RANGE(0x8fc1, 0x8fc1) AM_WRITENOP // overrun during initial screen clear +// AM_RANGE(0x8fe1, 0x8fe1) AM_WRITENOP // overrun during initial screen clear AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(carjmbre_videoram_w) AM_BASE_MEMBER(carjmbre_state, videoram) - AM_RANGE(0x9800, 0x985f) AM_WRITEONLY AM_BASE_SIZE_MEMBER(carjmbre_state, spriteram, spriteram_size) - AM_RANGE(0x9880, 0x98df) AM_WRITEONLY //spriteram mirror + AM_RANGE(0x9800, 0x985f) AM_MIRROR(0x80) AM_WRITEONLY AM_BASE_SIZE_MEMBER(carjmbre_state, spriteram, spriteram_size) AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_RANGE(0xa800, 0xa800) AM_READ_PORT("P2") AM_RANGE(0xb800, 0xb800) AM_READ_PORT("DSW") AM_WRITE(soundlatch_w) ADDRESS_MAP_END static ADDRESS_MAP_START( carjmbre_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x0fff) AM_ROM - AM_RANGE(0x1000, 0x10ff) AM_READNOP //look to be stray reads from 10/12/14/16/18xx - AM_RANGE(0x1200, 0x12ff) AM_READNOP - AM_RANGE(0x1400, 0x14ff) AM_READNOP - AM_RANGE(0x1600, 0x16ff) AM_READNOP - AM_RANGE(0x1800, 0x18ff) AM_READNOP + AM_RANGE(0x0000, 0x0fff) AM_MIRROR(0x1000) AM_ROM AM_RANGE(0x2000, 0x27ff) AM_RAM ADDRESS_MAP_END @@ -81,12 +76,12 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( carjmbre_sound_io_map, ADDRESS_SPACE_IO, 8 ) ADDRESS_MAP_GLOBAL_MASK(0xff) AM_RANGE(0x00, 0x00) AM_READ(soundlatch_r) - AM_RANGE(0x10, 0x10) AM_WRITENOP //?? written on init/0xff sound command reset + AM_RANGE(0x10, 0x10) AM_WRITENOP //?? written on init/0xff sound command reset AM_RANGE(0x20, 0x21) AM_DEVWRITE("ay1", ay8910_address_data_w) - AM_RANGE(0x22, 0x22) AM_WRITENOP //?? written before and after 0x21 with same value + AM_RANGE(0x22, 0x22) AM_WRITENOP //?? written before and after 0x21 with same value AM_RANGE(0x24, 0x24) AM_READNOP //?? AM_RANGE(0x30, 0x31) AM_DEVWRITE("ay2", ay8910_address_data_w) - AM_RANGE(0x32, 0x32) AM_WRITENOP //?? written before and after 0x31 with same value + AM_RANGE(0x32, 0x32) AM_WRITENOP //?? written before and after 0x31 with same value ADDRESS_MAP_END /************************************* @@ -117,26 +112,26 @@ static INPUT_PORTS_START( carjmbre ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL PORT_START("DSW") - PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:1,2") + PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:1,2") PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x03, DEF_STR( Free_Play ) ) - PORT_DIPNAME( 0x04, 0x00, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:3") + PORT_DIPNAME( 0x04, 0x00, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:3") PORT_DIPSETTING( 0x00, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x04, DEF_STR( 1C_6C ) ) - PORT_DIPNAME( 0x18, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW1:4,5") + PORT_DIPNAME( 0x18, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW1:4,5") PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x08, "4" ) PORT_DIPSETTING( 0x10, "5" ) - PORT_DIPSETTING( 0x18, "250 (Cheat)") - PORT_DIPNAME( 0x20, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW1:6") + PORT_DIPSETTING( 0x18, "Free") // 250 (cheat) + PORT_DIPNAME( 0x20, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW1:6") PORT_DIPSETTING( 0x00, "10k, then every 100k" ) PORT_DIPSETTING( 0x20, "20k, then every 100k" ) - PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SW1:7") + PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SW1:7") PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) - PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW1:8") + PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW1:8") PORT_DIPSETTING( 0x80, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) INPUT_PORTS_END diff --git a/src/mame/includes/carjmbre.h b/src/mame/includes/carjmbre.h index fb088a5227c..661ae70cbda 100644 --- a/src/mame/includes/carjmbre.h +++ b/src/mame/includes/carjmbre.h @@ -27,6 +27,7 @@ public: WRITE8_HANDLER( carjmbre_flipscreen_w ); WRITE8_HANDLER( carjmbre_bgcolor_w ); +WRITE8_HANDLER( carjmbre_8806_w ); WRITE8_HANDLER( carjmbre_videoram_w ); PALETTE_INIT( carjmbre ); diff --git a/src/mame/video/carjmbre.c b/src/mame/video/carjmbre.c index ada72525f40..7130204ac67 100644 --- a/src/mame/video/carjmbre.c +++ b/src/mame/video/carjmbre.c @@ -1,77 +1,78 @@ /*************************************************************************** Car Jamboree - Omori Electric CAD (OEC) 1981 + Omori Electric CAD (OEC) 1983 ***************************************************************************/ #include "emu.h" +#include "video/resnet.h" #include "includes/carjmbre.h" +// palette info from Popper (OEC 1983, very similar video hw) +static const res_net_decode_info carjmbre_decode_info = +{ + 1, // there may be two proms needed to construct color + 0, 63, // start/end + // R, G, B, + { 0, 0, 0, }, // offsets + { 0, 3, 6, }, // shifts + {0x07,0x07,0x03, } // masks +}; + +static const res_net_info carjmbre_net_info = +{ + RES_NET_VCC_5V | RES_NET_VBIAS_5V | RES_NET_VIN_TTL_OUT, + { + { RES_NET_AMP_NONE, 0, 0, 3, { 1000, 470, 220 } }, + { RES_NET_AMP_NONE, 0, 0, 3, { 1000, 470, 220 } }, + { RES_NET_AMP_NONE, 0, 0, 2, { 470, 220, 0 } } + } +}; + PALETTE_INIT( carjmbre ) { - int i, bit0, bit1, bit2, r, g, b; + rgb_t *rgb; - for (i = 0; i < machine->total_colors(); i++) - { - /* red component */ - bit0 = (*color_prom >> 0) & 0x01; - bit1 = (*color_prom >> 1) & 0x01; - bit2 = (*color_prom >> 2) & 0x01; - r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - /* green component */ - bit0 = (*color_prom >> 3) & 0x01; - bit1 = (*color_prom >> 4) & 0x01; - bit2 = (*color_prom >> 5) & 0x01; - g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - /* blue component */ - bit0 = 0; - bit1 = (*color_prom >> 6) & 0x01; - bit2 = (*color_prom >> 7) & 0x01; - b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - - palette_set_color(machine, i, MAKE_RGB(r,g,b)); - color_prom++; - } + rgb = compute_res_net_all(machine, color_prom, &carjmbre_decode_info, &carjmbre_net_info); + palette_set_colors(machine, 0, rgb, 64); + palette_normalize_range(machine->palette, 0, 63, 0, 255); + auto_free(machine, rgb); } + + WRITE8_HANDLER( carjmbre_flipscreen_w ) { carjmbre_state *state = space->machine->driver_data(); - state->flipscreen = data ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; + state->flipscreen = (data & 1) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; tilemap_set_flip_all(space->machine, state->flipscreen); } WRITE8_HANDLER( carjmbre_bgcolor_w ) { carjmbre_state *state = space->machine->driver_data(); - int oldbg, i; + data = ~data & 0x3f; - oldbg = state->bgcolor; - - state->bgcolor &= 0xff00 >> (offset * 8); - state->bgcolor |= ((~data) & 0xff) << (offset * 8); - - if ( oldbg != state->bgcolor) + if (data != state->bgcolor) { - for (i = 0; i < 64; i += 4) - palette_set_color_rgb(space->machine, i, (state->bgcolor & 0xff) * 0x50, - (state->bgcolor & 0xff) * 0x50, (state->bgcolor & 0xff)!=0 ? 0x50 : 0); + int i; + + state->bgcolor = data; + if (data & 3) + for (i = 0; i < 64; i += 4) + palette_set_color(space->machine, i, palette_get_color(space->machine, data)); + else + // restore to initial state (black) + for (i = 0; i < 64; i += 4) + palette_set_color(space->machine, i, RGB_BLACK); } } -static TILE_GET_INFO( get_carjmbre_tile_info ) +WRITE8_HANDLER( carjmbre_8806_w ) { - carjmbre_state *state = machine->driver_data(); - UINT32 tile_number = state->videoram[tile_index] & 0xff; - UINT8 attr = state->videoram[tile_index + 0x400]; - tile_number += (attr & 0x80) << 1; /* bank */ - SET_TILE_INFO( - 0, - tile_number, - (attr & 0x7), - 0); + // unknown, gets updated at same time as carjmbre_bgcolor_w } WRITE8_HANDLER( carjmbre_videoram_w ) @@ -84,6 +85,20 @@ WRITE8_HANDLER( carjmbre_videoram_w ) +static TILE_GET_INFO( get_carjmbre_tile_info ) +{ + carjmbre_state *state = machine->driver_data(); + UINT32 tile_number = state->videoram[tile_index] & 0xff; + UINT8 attr = state->videoram[tile_index + 0x400]; + tile_number += (attr & 0x80) << 1; /* bank */ + + SET_TILE_INFO( + 0, + tile_number, + attr & 0xf, + 0); +} + VIDEO_START( carjmbre ) { carjmbre_state *state = machine->driver_data(); @@ -102,8 +117,7 @@ SCREEN_UPDATE( carjmbre ) //76543210 //x------- graphic bank //-xxx---- unused - //----x--- ?? probably colour, only used for ramp and pond - //-----xxx colour + //----xxxx colour tilemap_draw(bitmap, cliprect, state->cj_tilemap, 0, 0); @@ -115,8 +129,7 @@ SCREEN_UPDATE( carjmbre ) //x------- flipy //-x------ flipx //--xx---- unused - //----x--- ?? probably colour - //-----xxx colour + //----xxxx colour //+3 x pos for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4) { @@ -127,26 +140,24 @@ SCREEN_UPDATE( carjmbre ) //unused sprites are marked with ypos <= 0x02 (or >= 0xfd if screen flipped) if (state->spriteram[troffs] > 0x02 && state->spriteram[troffs] < 0xfd) { + sx = state->spriteram[troffs + 3] - 7; + sy = 241 - state->spriteram[troffs]; + flipx = (state->spriteram[troffs + 2] & 0x40) >> 6; + flipy = (state->spriteram[troffs + 2] & 0x80) >> 7; + + if (state->flipscreen) { - sx = state->spriteram[troffs + 3] - 7; - sy = 241 - state->spriteram[troffs]; - flipx = (state->spriteram[troffs + 2] & 0x40) >> 6; - flipy = (state->spriteram[troffs + 2] & 0x80) >> 7; - - if (state->flipscreen) - { - sx = (256 + (226 - sx)) % 256; - sy = 242 - sy; - flipx = !flipx; - flipy = !flipy; - } - - drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1], - state->spriteram[troffs + 1], - state->spriteram[troffs + 2] & 0x07, - flipx,flipy, - sx,sy,0); + sx = (256 + (226 - sx)) % 256; + sy = 242 - sy; + flipx = !flipx; + flipy = !flipy; } + + drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1], + state->spriteram[troffs + 1], + state->spriteram[troffs + 2] & 0xf, + flipx,flipy, + sx,sy,0); } } return 0;