diff --git a/src/mame/drivers/battlex.c b/src/mame/drivers/battlex.c index e97ddae3e76..0f4ff76614f 100644 --- a/src/mame/drivers/battlex.c +++ b/src/mame/drivers/battlex.c @@ -7,7 +7,7 @@ Stephh's notes : - I don't know exactly how to call the "Free Play" Dip Switch 8( - It's effect is the following : + Its effect is the following : * you need to insert at least one credit and start a game * when the game is over, you can start another games WITHOUT inserting another coins @@ -22,7 +22,9 @@ - missing starfield - game speed, its seems to be controlled by the IRQ's, how fast should it - be? firing seems frustratingly inconsistant + be? firing seems frustratingly inconsistant (better with PORT_IMPULSE) + + - background tile colors, not understood well **************************************************************************** @@ -47,6 +49,27 @@ #include "includes/battlex.h" +static INTERRUPT_GEN( battlex_interrupt ) +{ + battlex_state *state = device->machine->driver_data(); + state->in0_b4 = 1; + cpu_set_input_line(device, 0, ASSERT_LINE); +} + +static CUSTOM_INPUT( battlex_in0_b4_r ) +{ + battlex_state *state = field->port->machine->driver_data(); + UINT32 ret = state->in0_b4; + if (state->in0_b4) + { + cputag_set_input_line(field->port->machine, "maincpu", 0, CLEAR_LINE); + state->in0_b4 = 0; + } + + return ret; +} + + /************************************* * * Memory maps @@ -72,15 +95,12 @@ static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 ) /* verify all of these */ AM_RANGE(0x22, 0x23) AM_DEVWRITE("aysnd", ay8910_data_address_w) - - /* 0x30 looks like scroll, but can't be ? changes (increases or decreases) - depending on the direction your ship is facing on lev 2. at least */ - AM_RANGE(0x30, 0x30) AM_WRITENOP - + AM_RANGE(0x30, 0x30) AM_WRITE(battlex_scroll_starfield_w) AM_RANGE(0x32, 0x32) AM_WRITE(battlex_scroll_x_lsb_w) AM_RANGE(0x33, 0x33) AM_WRITE(battlex_scroll_x_msb_w) ADDRESS_MAP_END + /************************************* * * Input ports @@ -88,21 +108,19 @@ ADDRESS_MAP_END *************************************/ static INPUT_PORTS_START( battlex ) - PORT_START("DSW1") /* IN0 */ + PORT_START("DSW1") /* IN0 */ PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coin_A ) ) PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x03, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) ) - PORT_DIPNAME( 0x04, 0x04, DEF_STR( Allow_Continue ) ) // Not on 1st stage + PORT_DIPNAME( 0x04, 0x04, DEF_STR( Allow_Continue ) ) // Not on 1st stage PORT_DIPSETTING( 0x00, DEF_STR( No ) ) PORT_DIPSETTING( 0x04, DEF_STR( Yes ) ) PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x08, DEF_STR( On ) ) - PORT_DIPNAME( 0x10, 0x00, "Freeze" ) // VBLANK ? - PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x10, DEF_STR( On ) ) + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(battlex_in0_b4_r, NULL) PORT_DIPNAME( 0x20, 0x20, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x20, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) @@ -114,24 +132,24 @@ static INPUT_PORTS_START( battlex ) PORT_START("SYSTEM") /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 ) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_IMPULSE(4) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_IMPULSE(4) PORT_COCKTAIL PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START("INPUTS") /* IN2 */ - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL - PORT_START("DSW2") /* IN3 */ + PORT_START("DSW2") /* IN3 */ PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coin_B ) ) PORT_DIPSETTING( 0x07, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x05, DEF_STR( 2C_1C ) ) @@ -157,7 +175,6 @@ static INPUT_PORTS_START( battlex ) INPUT_PORTS_END - /************************************* * * Graphics definitions @@ -167,15 +184,14 @@ INPUT_PORTS_END static const gfx_layout battlex_charlayout = { 8,8, - RGN_FRAC(1,1), - 4, - { 0,1,2,3 }, - { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4 }, - { 0*8*4, 1*8*4, 2*8*4, 3*8*4, 4*8*4, 5*8*4, 6*8*4, 7*8*4 }, - 8*8*4 + RGN_FRAC(1,3), + 3, + { 0,RGN_FRAC(1,3),RGN_FRAC(2,3) }, + { 7,6,5,4,3,2,1,0 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, + 8*8 }; - static const gfx_layout battlex_spritelayout = { 16,16, @@ -189,10 +205,9 @@ static const gfx_layout battlex_spritelayout = 16*16 }; - static GFXDECODE_START( battlex ) - GFXDECODE_ENTRY( "gfx1", 0, battlex_charlayout, 0, 8 ) - GFXDECODE_ENTRY( "gfx2", 0, battlex_spritelayout, 16*8, 8 ) + GFXDECODE_ENTRY( "gfx1", 0, battlex_charlayout, 0, 8 ) + GFXDECODE_ENTRY( "gfx2", 0, battlex_spritelayout, 0, 8 ) GFXDECODE_END @@ -202,27 +217,51 @@ GFXDECODE_END * *************************************/ +static const ay8910_interface battlex_ay8910_interface = +{ + AY8910_LEGACY_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL +}; + +static MACHINE_START( battlex ) +{ + battlex_state *state = machine->driver_data(); + + /* register for save states */ + state->save_item(NAME(state->scroll_lsb)); + state->save_item(NAME(state->scroll_msb)); + state->save_item(NAME(state->starfield_enabled)); + state->save_item(NAME(state->in0_b4)); +} + static MACHINE_RESET( battlex ) { battlex_state *state = machine->driver_data(); state->scroll_lsb = 0; state->scroll_msb = 0; + state->starfield_enabled = 0; + state->in0_b4 = 0; } static MACHINE_CONFIG_START( battlex, battlex_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80,10000000/2 ) /* 10 MHz, divided ? (Z80A CPU) */ + MCFG_CPU_ADD("maincpu", Z80,XTAL_10MHz/4 ) // ? MCFG_CPU_PROGRAM_MAP(battlex_map) MCFG_CPU_IO_MAP(io_map) - MCFG_CPU_VBLANK_INT_HACK(irq0_line_hold,8) /* controls game speed? */ + MCFG_CPU_PERIODIC_INT(battlex_interrupt,400) /* controls game speed? */ + MCFG_MACHINE_START(battlex) MCFG_MACHINE_RESET(battlex) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(56) /* The video syncs at 15.8k H and 56 V (www.klov.com) */ + MCFG_SCREEN_REFRESH_RATE(60) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) MCFG_SCREEN_SIZE(32*8, 32*8) @@ -230,14 +269,13 @@ static MACHINE_CONFIG_START( battlex, battlex_state ) MCFG_SCREEN_UPDATE(battlex) MCFG_GFXDECODE(battlex) - MCFG_PALETTE_LENGTH(16*8+64) - - MCFG_PALETTE_INIT(battlex) + MCFG_PALETTE_LENGTH(64) MCFG_VIDEO_START(battlex) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("aysnd", AY8910, 10000000/8) + MCFG_SOUND_ADD("aysnd", AY8910, XTAL_10MHz/8) // ? + MCFG_SOUND_CONFIG(battlex_ay8910_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) MACHINE_CONFIG_END @@ -257,20 +295,18 @@ ROM_START( battlex ) ROM_LOAD( "p-rom5.2", 0x4000, 0x1000, CRC(ceb63d38) SHA1(92cab905d009c59115f52172ba7d01c8ff8991d7) ) ROM_LOAD( "p-rom6.1", 0x5000, 0x1000, CRC(6923f601) SHA1(e6c33cbd8d8679299d7b2c568d56f96ed3073971) ) - ROM_REGION( 0x4000, "gfx1", ROMREGION_ERASE00 ) - /* filled in later */ -// ROM_LOAD( "2732.e", 0x0000, 0x1000, CRC(126842b7) SHA1(2da4f64e077232c1dd0853d07d801f9781517850) ) - ROM_REGION( 0x3000, "gfx2", 0 ) - ROM_LOAD( "2732.f", 0x0000, 0x1000, CRC(2b69287a) SHA1(30c0edaec44118b95ec390bd41c1bd49a2802451) ) - ROM_LOAD( "2732.h", 0x1000, 0x1000, CRC(9f4c3bdd) SHA1(e921ecafefe54c033d05d9cd289808e971ac7940) ) - ROM_LOAD( "2732.j", 0x2000, 0x1000, CRC(c1345b05) SHA1(17194c8ec961990222bd295ff1d036a64f497b0e) ) + ROM_LOAD( "1a_f.6f", 0x0000, 0x1000, CRC(2b69287a) SHA1(30c0edaec44118b95ec390bd41c1bd49a2802451) ) + ROM_LOAD( "1a_h.6h", 0x1000, 0x1000, CRC(9f4c3bdd) SHA1(e921ecafefe54c033d05d9cd289808e971ac7940) ) + ROM_LOAD( "1a_j.6j", 0x2000, 0x1000, CRC(c1345b05) SHA1(17194c8ec961990222bd295ff1d036a64f497b0e) ) - ROM_REGION( 0x1000, "user1", 0 ) /* line colours? or bad? */ - ROM_LOAD( "2732.d", 0x0000, 0x1000, CRC(750a46ef) SHA1(b6ab93e084ab0b7c6ad90ee6431bc1b7ab9ed46d) ) + ROM_REGION( 0x3000, "gfx1", ROMREGION_ERASE00 ) // filled in later - ROM_REGION( 0x1000, "user2", 0 ) - ROM_LOAD( "2732.e", 0x0000, 0x1000, CRC(126842b7) SHA1(2da4f64e077232c1dd0853d07d801f9781517850) ) + ROM_REGION( 0x1000, "user2", 0 ) // gfx1 1bpp gfxdata + ROM_LOAD( "1a_e.6e", 0x0000, 0x1000, CRC(126842b7) SHA1(2da4f64e077232c1dd0853d07d801f9781517850) ) + + ROM_REGION( 0x1000, "user1", 0 ) // gfx1 colormask, bad? + ROM_LOAD( "1a_d.6d", 0x0000, 0x1000, CRC(750a46ef) SHA1(b6ab93e084ab0b7c6ad90ee6431bc1b7ab9ed46d) ) ROM_END @@ -282,33 +318,29 @@ ROM_END static DRIVER_INIT( battlex ) { - UINT8 *cold = machine->region("user1")->base(); - UINT8 *mskd = machine->region("user2")->base(); + UINT8 *colormask = machine->region("user1")->base(); + UINT8 *gfxdata = machine->region("user2")->base(); UINT8 *dest = machine->region("gfx1")->base(); - int outcount; + int tile, line, bit; - /* convert gfx data from 1bpp + color block mask to straight 4bpp */ - for (outcount = 0; outcount < (0x1000/8); outcount++) + /* convert gfx data from 1bpp + color block mask to straight 3bpp */ + for (tile = 0; tile < 512; tile++) { - int linecount; - for (linecount = 0; linecount < 8; linecount ++) + for (line = 0; line < 8; line ++) { - int bitmask = 0x01; - int bitcount; - - for (bitcount = 0; bitcount < 8 ; bitcount ++) + for (bit = 0; bit < 8 ; bit ++) { - int bit, col; - bit = (mskd[outcount * 8 + linecount] & bitmask) >> bitcount; + int plane; + int color = colormask[tile << 3 | line]; + int data = gfxdata[tile << 3 | line] >> bit & 1; + if (!data) color >>= 4; - if (bit) - col = (cold[outcount * 8 + (linecount & ~1) + (bitcount / 4)] & 0x0f) << 4; - else - col = (cold[outcount * 8 + (linecount & ~1) + (bitcount / 4)] & 0xf0); - - dest[outcount * 32 + linecount * 4 + bitcount /2] |= (col >> (4 * (bitcount & 1))); - bitmask = bitmask << 1; + for (plane = 2; plane >= 0; plane--) + { + dest[tile << 3 | line | (plane << 12)] |= (color & 1) << bit; + color >>= 1; + } } } } @@ -321,4 +353,4 @@ static DRIVER_INIT( battlex ) * *************************************/ -GAME( 1982, battlex, 0, battlex, battlex, battlex, ROT180, "Omori Electric Co., Ltd.", "Battle Cross", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) +GAME( 1982, battlex, 0, battlex, battlex, battlex, ROT180, "Omori Electric Co., Ltd.", "Battle Cross", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/battlex.h b/src/mame/includes/battlex.h index 814f73c3ea6..3ccd3dcbfe1 100644 --- a/src/mame/includes/battlex.h +++ b/src/mame/includes/battlex.h @@ -10,13 +10,16 @@ public: battlex_state(running_machine &machine, const driver_device_config_base &config) : driver_device(machine, config) { } + UINT8 in0_b4; + /* memory pointers */ UINT8 * videoram; UINT8 * spriteram; /* video-related */ tilemap_t *bg_tilemap; - int scroll_lsb, scroll_msb; + UINT8 scroll_lsb, scroll_msb; + UINT8 starfield_enabled; }; @@ -26,8 +29,8 @@ extern WRITE8_HANDLER( battlex_palette_w ); extern WRITE8_HANDLER( battlex_videoram_w ); extern WRITE8_HANDLER( battlex_scroll_x_lsb_w ); extern WRITE8_HANDLER( battlex_scroll_x_msb_w ); +extern WRITE8_HANDLER( battlex_scroll_starfield_w ); extern WRITE8_HANDLER( battlex_flipscreen_w ); -extern PALETTE_INIT( battlex ); extern VIDEO_START( battlex ); extern SCREEN_UPDATE( battlex ); diff --git a/src/mame/video/battlex.c b/src/mame/video/battlex.c index de4ce9d382a..db9190150dd 100644 --- a/src/mame/video/battlex.c +++ b/src/mame/video/battlex.c @@ -7,37 +7,10 @@ #include "emu.h" #include "includes/battlex.h" -PALETTE_INIT( battlex ) -{ - int i, col; - - for (col = 0; col < 8; col++) - { - for (i = 0; i < 16; i++) - { - int data = i | col; - int r = pal1bit(data >> 0); - int b = pal1bit(data >> 1); - int g = pal1bit(data >> 2); - -#if 0 - /* from Tim's shots, bit 3 seems to have no effect (see e.g. Laser Ship on title screen) */ - if (i & 8) - { - r /= 2; - g /= 2; - b /= 2; - } -#endif - - palette_set_color(machine, i + 16 * col, MAKE_RGB(r,g,b)); - } - } -} WRITE8_HANDLER( battlex_palette_w ) { - palette_set_color_rgb(space->machine, 16 * 8 + offset, pal1bit(data >> 0), pal1bit(data >> 2), pal1bit(data >> 1)); + palette_set_color_rgb(space->machine, offset, pal1bit(data >> 0), pal1bit(data >> 2), pal1bit(data >> 1)); } WRITE8_HANDLER( battlex_scroll_x_lsb_w ) @@ -52,6 +25,10 @@ WRITE8_HANDLER( battlex_scroll_x_msb_w ) state->scroll_msb = data; } +WRITE8_HANDLER( battlex_scroll_starfield_w ) +{ +} + WRITE8_HANDLER( battlex_videoram_w ) { battlex_state *state = space->machine->driver_data(); @@ -61,22 +38,22 @@ WRITE8_HANDLER( battlex_videoram_w ) WRITE8_HANDLER( battlex_flipscreen_w ) { - /* bit 4 is used, but for what? */ + battlex_state *state = space->machine->driver_data(); + state->starfield_enabled = data & 0x10; - /* bit 7 is flip screen */ - - if (flip_screen_get(space->machine) != (data & 0x80)) + if (flip_screen_get(space->machine) != (data >> 7)) { flip_screen_set(space->machine, data & 0x80); tilemap_mark_all_tiles_dirty_all(space->machine); } } + static TILE_GET_INFO( get_bg_tile_info ) { battlex_state *state = machine->driver_data(); int tile = state->videoram[tile_index * 2] | (((state->videoram[tile_index * 2 + 1] & 0x01)) << 8); - int color = (state->videoram[tile_index * 2 + 1] & 0x0e) >> 1; + int color = (state->videoram[tile_index * 2 + 1] & 0x0e) >> 1; // high bits unused SET_TILE_INFO(0, tile, color, 0); } @@ -84,10 +61,7 @@ static TILE_GET_INFO( get_bg_tile_info ) VIDEO_START( battlex ) { battlex_state *state = machine->driver_data(); - state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); - state->save_item(NAME(state->scroll_lsb)); - state->save_item(NAME(state->scroll_msb)); } static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) @@ -120,6 +94,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect } + SCREEN_UPDATE(battlex) { battlex_state *state = screen->machine->driver_data(); @@ -127,5 +102,6 @@ SCREEN_UPDATE(battlex) tilemap_set_scrollx(state->bg_tilemap, 0, state->scroll_lsb | (state->scroll_msb << 8)); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); draw_sprites(screen->machine, bitmap, cliprect); + return 0; }