diff options
| author | 2008-01-11 11:30:28 +0000 | |
|---|---|---|
| committer | 2008-01-11 11:30:28 +0000 | |
| commit | 3bc90058e9a6fd4553412d5c5ad95fe84608646d (patch) | |
| tree | 36353f8aafc1a46ce630f666b71fc85797fde631 /src | |
| parent | f8f4dad549c027d25d5e14fad00db48542ec60bf (diff) | |
Complete memory map from Nicola's ancient notes.
General code clean-up
Diffstat (limited to 'src')
| -rw-r--r-- | src/mame/drivers/taitosj.c | 518 | ||||
| -rw-r--r-- | src/mame/video/taitosj.c | 880 |
2 files changed, 635 insertions, 763 deletions
diff --git a/src/mame/drivers/taitosj.c b/src/mame/drivers/taitosj.c index 531c2b48654..bdfb10a9d17 100644 --- a/src/mame/drivers/taitosj.c +++ b/src/mame/drivers/taitosj.c @@ -151,7 +151,7 @@ Notes: Kickstart Wheelie King : - additional ram @ $d800-$dfff (scroll ram + ??) -- taitosj_colorbank_w @ $d000-$d001 +- color bank @ $d000-$d001 - taitosj_scroll @ $d002-$d007 - strange controls : - 'revolve type' - 3 pos switch (gears) + button/pedal (accel) @@ -190,26 +190,30 @@ WRITE8_HANDLER( alpine_protection_w ); WRITE8_HANDLER( alpinea_bankswitch_w ); READ8_HANDLER( alpine_port_2_r ); -extern UINT8 *taitosj_videoram2,*taitosj_videoram3; +extern UINT8 *taitosj_videoram_1; +extern UINT8 *taitosj_videoram_2; +extern UINT8 *taitosj_videoram_3; +extern UINT8 *taitosj_spriteram; +extern UINT8 *taitosj_paletteram; extern UINT8 *taitosj_characterram; extern UINT8 *taitosj_scroll; extern UINT8 *taitosj_colscrolly; extern UINT8 *taitosj_gfxpointer; -extern UINT8 *taitosj_colorbank,*taitosj_video_priority; +extern UINT8 *taitosj_colorbank; +extern UINT8 *taitosj_video_mode; +extern UINT8 *taitosj_video_priority; +extern UINT8 *taitosj_collision_reg; extern UINT8 *kikstart_scrollram; + PALETTE_INIT( taitosj ); READ8_HANDLER( taitosj_gfxrom_r ); -WRITE8_HANDLER( taitosj_videoram2_w ); -WRITE8_HANDLER( taitosj_videoram3_w ); -WRITE8_HANDLER( taitosj_paletteram_w ); -WRITE8_HANDLER( taitosj_colorbank_w ); -WRITE8_HANDLER( taitosj_videoenable_w ); +WRITE8_HANDLER( taitosj_videoe_w ); WRITE8_HANDLER( taitosj_characterram_w ); WRITE8_HANDLER( junglhbr_characterram_w ); -READ8_HANDLER( taitosj_collision_reg_r ); WRITE8_HANDLER( taitosj_collision_reg_clear_w ); VIDEO_START( taitosj ); VIDEO_UPDATE( taitosj ); +VIDEO_UPDATE( kikstart ); static UINT8 sndnmi_disable = 1; @@ -225,248 +229,185 @@ static WRITE8_HANDLER( taitosj_soundcommand_w ) if (!sndnmi_disable) cpunum_set_input_line(1,INPUT_LINE_NMI,PULSE_LINE); } -static UINT8 in5; +static UINT8 input_port_4_f0; -static WRITE8_HANDLER( in5_w ) +static WRITE8_HANDLER( input_port_4_f0_w ) { - in5 = data & 0xf0; + input_port_4_f0 = data >> 4; } -static READ8_HANDLER( in5_r ) +static UINT32 input_port_4_f0_r(void *param) { - return (input_port_4_r(0) & 0x0f) | (in5 & 0xf0); + return input_port_4_f0; } -static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x5fff) AM_READ(MRA8_ROM) - AM_RANGE(0x6000, 0x7fff) AM_READ(MRA8_BANK1) - AM_RANGE(0x8000, 0x87ff) AM_READ(MRA8_RAM) - AM_RANGE(0x8800, 0x8800) AM_READ(taitosj_fake_data_r) - AM_RANGE(0x8801, 0x8801) AM_READ(taitosj_fake_status_r) - AM_RANGE(0xc000, 0xcfff) AM_READ(MRA8_RAM) - AM_RANGE(0xd000, 0xd05f) AM_READ(MRA8_RAM) - AM_RANGE(0xd100, 0xd1ff) AM_READ(MRA8_RAM) - AM_RANGE(0xd400, 0xd403) AM_READ(taitosj_collision_reg_r) - AM_RANGE(0xd404, 0xd404) AM_READ(taitosj_gfxrom_r) - AM_RANGE(0xd408, 0xd408) AM_READ(input_port_0_r) /* IN0 */ - AM_RANGE(0xd409, 0xd409) AM_READ(input_port_1_r) /* IN1 */ - AM_RANGE(0xd40a, 0xd40a) AM_READ(input_port_5_r) /* DSW1 */ - AM_RANGE(0xd40b, 0xd40b) AM_READ(input_port_2_r) /* IN2 */ - AM_RANGE(0xd40c, 0xd40c) AM_READ(input_port_3_r) /* Service */ - AM_RANGE(0xd40d, 0xd40d) AM_READ(in5_r) - AM_RANGE(0xd40f, 0xd40f) AM_READ(AY8910_read_port_0_r) /* DSW2 and DSW3 */ - AM_RANGE(0xe000, 0xefff) AM_READ(MRA8_ROM) -ADDRESS_MAP_END -static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x7fff) AM_WRITE(MWA8_ROM) - AM_RANGE(0x8000, 0x87ff) AM_WRITE(MWA8_RAM) - AM_RANGE(0x8800, 0x8800) AM_WRITE(taitosj_fake_data_w) +static ADDRESS_MAP_START( taitosj_main_nomcu_map, ADDRESS_SPACE_PROGRAM, 8 ) + AM_RANGE(0x0000, 0x5fff) AM_ROM + AM_RANGE(0x6000, 0x7fff) AM_READWRITE(MRA8_BANK1, MWA8_ROM) + AM_RANGE(0x8000, 0x87ff) AM_RAM + AM_RANGE(0x8800, 0x8800) AM_MIRROR(0x07fe) AM_READWRITE(taitosj_fake_data_r, taitosj_fake_data_w) + AM_RANGE(0x8801, 0x8801) AM_MIRROR(0x07fe) AM_READ(taitosj_fake_status_r) AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE(&taitosj_characterram) - AM_RANGE(0xc000, 0xc3ff) AM_WRITE(MWA8_RAM) - AM_RANGE(0xc400, 0xc7ff) AM_WRITE(videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size) - AM_RANGE(0xc800, 0xcbff) AM_WRITE(taitosj_videoram2_w) AM_BASE(&taitosj_videoram2) - AM_RANGE(0xcc00, 0xcfff) AM_WRITE(taitosj_videoram3_w) AM_BASE(&taitosj_videoram3) - AM_RANGE(0xd000, 0xd05f) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_colscrolly) - AM_RANGE(0xd100, 0xd17f) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size) - AM_RANGE(0xd180, 0xd1ff) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram_2) AM_SIZE(&spriteram_2_size) - AM_RANGE(0xd200, 0xd27f) AM_WRITE(taitosj_paletteram_w) AM_BASE(&paletteram) - AM_RANGE(0xd300, 0xd300) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_video_priority) - AM_RANGE(0xd40e, 0xd40e) AM_WRITE(AY8910_control_port_0_w) - AM_RANGE(0xd40f, 0xd40f) AM_WRITE(AY8910_write_port_0_w) - AM_RANGE(0xd500, 0xd505) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_scroll) - AM_RANGE(0xd506, 0xd507) AM_WRITE(taitosj_colorbank_w) AM_BASE(&taitosj_colorbank) - AM_RANGE(0xd508, 0xd508) AM_WRITE(taitosj_collision_reg_clear_w) - AM_RANGE(0xd509, 0xd50a) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_gfxpointer) - AM_RANGE(0xd50b, 0xd50b) AM_WRITE(taitosj_soundcommand_w) - AM_RANGE(0xd50d, 0xd50d) AM_WRITE(MWA8_RAM) /*watchdog_reset_w*/ /* Bio Attack reset sometimes after you die */ - AM_RANGE(0xd50e, 0xd50e) AM_WRITE(taitosj_bankswitch_w) - AM_RANGE(0xd50f, 0xd50f) AM_WRITE(MWA8_NOP) - AM_RANGE(0xd600, 0xd600) AM_WRITE(taitosj_videoenable_w) - AM_RANGE(0xe000, 0xefff) AM_WRITE(MWA8_ROM) + AM_RANGE(0xc000, 0xc3ff) AM_RAM + AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE(&taitosj_videoram_1) + AM_RANGE(0xc800, 0xcbff) AM_RAM AM_BASE(&taitosj_videoram_2) + AM_RANGE(0xcc00, 0xcfff) AM_RAM AM_BASE(&taitosj_videoram_3) + AM_RANGE(0xd000, 0xd05f) AM_RAM AM_BASE(&taitosj_colscrolly) + AM_RANGE(0xd100, 0xd1ff) AM_RAM AM_BASE(&taitosj_spriteram) + AM_RANGE(0xd200, 0xd27f) AM_MIRROR(0x0080) AM_RAM AM_BASE(&taitosj_paletteram) + AM_RANGE(0xd300, 0xd300) AM_MIRROR(0x00ff) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_video_priority) + AM_RANGE(0xd400, 0xd403) AM_MIRROR(0x00f0) AM_READ(MRA8_RAM) AM_BASE(&taitosj_collision_reg) + AM_RANGE(0xd404, 0xd404) AM_MIRROR(0x00f3) AM_READ(taitosj_gfxrom_r) + AM_RANGE(0xd408, 0xd408) AM_MIRROR(0x00f0) AM_READ(input_port_0_r) /* IN0 */ + AM_RANGE(0xd409, 0xd409) AM_MIRROR(0x00f0) AM_READ(input_port_1_r) /* IN1 */ + AM_RANGE(0xd40a, 0xd40a) AM_MIRROR(0x00f0) AM_READ(input_port_5_r) /* DSW1 */ + AM_RANGE(0xd40b, 0xd40b) AM_MIRROR(0x00f0) AM_READ(input_port_2_r) /* IN2 */ + AM_RANGE(0xd40c, 0xd40c) AM_MIRROR(0x00f0) AM_READ(input_port_3_r) /* Service */ + AM_RANGE(0xd40d, 0xd40d) AM_MIRROR(0x00f0) AM_READ(input_port_4_r) + AM_RANGE(0xd40e, 0xd40e) AM_MIRROR(0x00f0) AM_WRITE(AY8910_control_port_0_w) + AM_RANGE(0xd40f, 0xd40f) AM_MIRROR(0x00f0) AM_READWRITE(AY8910_read_port_0_r, AY8910_write_port_0_w) /* DSW2 and DSW3 */ + AM_RANGE(0xd500, 0xd505) AM_MIRROR(0x00f0) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_scroll) + AM_RANGE(0xd506, 0xd507) AM_MIRROR(0x00f0) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_colorbank) + AM_RANGE(0xd508, 0xd508) AM_MIRROR(0x00f0) AM_WRITE(taitosj_collision_reg_clear_w) + AM_RANGE(0xd509, 0xd50a) AM_MIRROR(0x00f0) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_gfxpointer) + AM_RANGE(0xd50b, 0xd50b) AM_MIRROR(0x00f0) AM_WRITE(taitosj_soundcommand_w) + AM_RANGE(0xd50d, 0xd50d) AM_MIRROR(0x00f0) AM_WRITE(MWA8_RAM) /*watchdog_reset_w*/ /* Bio Attack sometimes resets after you die */ + AM_RANGE(0xd50e, 0xd50e) AM_MIRROR(0x00f0) AM_WRITE(taitosj_bankswitch_w) + AM_RANGE(0xd50f, 0xd50f) AM_MIRROR(0x00f0) AM_WRITE(MWA8_NOP) + AM_RANGE(0xd600, 0xd600) AM_MIRROR(0x00ff) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_video_mode) + AM_RANGE(0xd700, 0xdfff) AM_NOP + AM_RANGE(0xe000, 0xffff) AM_ROM ADDRESS_MAP_END -/* only difference is taitosj_fake_ replaced with taitosj_mcu_ */ -static ADDRESS_MAP_START( mcu_readmem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x5fff) AM_READ(MRA8_ROM) - AM_RANGE(0x6000, 0x7fff) AM_READ(MRA8_BANK1) - AM_RANGE(0x8000, 0x87ff) AM_READ(MRA8_RAM) - AM_RANGE(0x8800, 0x8800) AM_READ(taitosj_mcu_data_r) - AM_RANGE(0x8801, 0x8801) AM_READ(taitosj_mcu_status_r) - AM_RANGE(0xc000, 0xcfff) AM_READ(MRA8_RAM) - AM_RANGE(0xd000, 0xd05f) AM_READ(MRA8_RAM) - AM_RANGE(0xd100, 0xd1ff) AM_READ(MRA8_RAM) - AM_RANGE(0xd400, 0xd403) AM_READ(taitosj_collision_reg_r) - AM_RANGE(0xd404, 0xd404) AM_READ(taitosj_gfxrom_r) - AM_RANGE(0xd408, 0xd408) AM_READ(input_port_0_r) /* IN0 */ - AM_RANGE(0xd409, 0xd409) AM_READ(input_port_1_r) /* IN1 */ - AM_RANGE(0xd40a, 0xd40a) AM_READ(input_port_5_r) /* DSW1 */ - AM_RANGE(0xd40b, 0xd40b) AM_READ(input_port_2_r) /* IN2 */ - AM_RANGE(0xd40c, 0xd40c) AM_READ(input_port_3_r) /* Service */ - AM_RANGE(0xd40d, 0xd40d) AM_READ(in5_r) - AM_RANGE(0xd40f, 0xd40f) AM_READ(AY8910_read_port_0_r) /* DSW2 and DSW3 */ - AM_RANGE(0xe000, 0xefff) AM_READ(MRA8_ROM) -ADDRESS_MAP_END -static ADDRESS_MAP_START( mcu_writemem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x7fff) AM_WRITE(MWA8_ROM) - AM_RANGE(0x8000, 0x87ff) AM_WRITE(MWA8_RAM) - AM_RANGE(0x8800, 0x8800) AM_WRITE(taitosj_mcu_data_w) +/* only difference is taitosj_fake_ replaced with taitosj_mcu_ */ +static ADDRESS_MAP_START( taitosj_main_mcu_map, ADDRESS_SPACE_PROGRAM, 8 ) + AM_RANGE(0x0000, 0x5fff) AM_ROM + AM_RANGE(0x6000, 0x7fff) AM_READWRITE(MRA8_BANK1, MWA8_ROM) + AM_RANGE(0x8000, 0x87ff) AM_RAM + AM_RANGE(0x8800, 0x8800) AM_MIRROR(0x07fe) AM_READWRITE(taitosj_mcu_data_r, taitosj_mcu_data_w) + AM_RANGE(0x8801, 0x8801) AM_MIRROR(0x07fe) AM_READ(taitosj_mcu_status_r) AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE(&taitosj_characterram) - AM_RANGE(0xc400, 0xc7ff) AM_WRITE(videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size) - AM_RANGE(0xc800, 0xcbff) AM_WRITE(taitosj_videoram2_w) AM_BASE(&taitosj_videoram2) - AM_RANGE(0xc000, 0xc3ff) AM_WRITE(MWA8_RAM) - AM_RANGE(0xcc00, 0xcfff) AM_WRITE(taitosj_videoram3_w) AM_BASE(&taitosj_videoram3) - AM_RANGE(0xd000, 0xd05f) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_colscrolly) - AM_RANGE(0xd100, 0xd17f) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size) - AM_RANGE(0xd180, 0xd1ff) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram_2) AM_SIZE(&spriteram_2_size) - AM_RANGE(0xd200, 0xd27f) AM_WRITE(taitosj_paletteram_w) AM_BASE(&paletteram) - AM_RANGE(0xd300, 0xd300) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_video_priority) - AM_RANGE(0xd40e, 0xd40e) AM_WRITE(AY8910_control_port_0_w) - AM_RANGE(0xd40f, 0xd40f) AM_WRITE(AY8910_write_port_0_w) - AM_RANGE(0xd500, 0xd505) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_scroll) - AM_RANGE(0xd506, 0xd507) AM_WRITE(taitosj_colorbank_w) AM_BASE(&taitosj_colorbank) - AM_RANGE(0xd508, 0xd508) AM_WRITE(taitosj_collision_reg_clear_w) - AM_RANGE(0xd509, 0xd50a) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_gfxpointer) - AM_RANGE(0xd50b, 0xd50b) AM_WRITE(taitosj_soundcommand_w) - AM_RANGE(0xd50d, 0xd50d) AM_WRITE(watchdog_reset_w) - AM_RANGE(0xd50e, 0xd50e) AM_WRITE(taitosj_bankswitch_w) - AM_RANGE(0xd600, 0xd600) AM_WRITE(taitosj_videoenable_w) - AM_RANGE(0xe000, 0xefff) AM_WRITE(MWA8_ROM) + AM_RANGE(0xc000, 0xc3ff) AM_RAM + AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE(&taitosj_videoram_1) + AM_RANGE(0xc800, 0xcbff) AM_RAM AM_BASE(&taitosj_videoram_2) + AM_RANGE(0xcc00, 0xcfff) AM_RAM AM_BASE(&taitosj_videoram_3) + AM_RANGE(0xd000, 0xd05f) AM_RAM AM_BASE(&taitosj_colscrolly) + AM_RANGE(0xd100, 0xd1ff) AM_RAM AM_BASE(&taitosj_spriteram) + AM_RANGE(0xd200, 0xd27f) AM_MIRROR(0x0080) AM_RAM AM_BASE(&taitosj_paletteram) + AM_RANGE(0xd300, 0xd300) AM_MIRROR(0x00ff) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_video_priority) + AM_RANGE(0xd400, 0xd403) AM_MIRROR(0x00f0) AM_READ(MRA8_RAM) AM_BASE(&taitosj_collision_reg) + AM_RANGE(0xd404, 0xd404) AM_MIRROR(0x00f3) AM_READ(taitosj_gfxrom_r) + AM_RANGE(0xd408, 0xd408) AM_MIRROR(0x00f0) AM_READ(input_port_0_r) /* IN0 */ + AM_RANGE(0xd409, 0xd409) AM_MIRROR(0x00f0) AM_READ(input_port_1_r) /* IN1 */ + AM_RANGE(0xd40a, 0xd40a) AM_MIRROR(0x00f0) AM_READ(input_port_5_r) /* DSW1 */ + AM_RANGE(0xd40b, 0xd40b) AM_MIRROR(0x00f0) AM_READ(input_port_2_r) /* IN2 */ + AM_RANGE(0xd40c, 0xd40c) AM_MIRROR(0x00f0) AM_READ(input_port_3_r) /* Service */ + AM_RANGE(0xd40d, 0xd40d) AM_MIRROR(0x00f0) AM_READ(input_port_4_r) + AM_RANGE(0xd40e, 0xd40e) AM_MIRROR(0x00f0) AM_WRITE(AY8910_control_port_0_w) + AM_RANGE(0xd40f, 0xd40f) AM_MIRROR(0x00f0) AM_READWRITE(AY8910_read_port_0_r, AY8910_write_port_0_w) /* DSW2 and DSW3 */ + AM_RANGE(0xd500, 0xd505) AM_MIRROR(0x00f0) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_scroll) + AM_RANGE(0xd506, 0xd507) AM_MIRROR(0x00f0) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_colorbank) + AM_RANGE(0xd508, 0xd508) AM_MIRROR(0x00f0) AM_WRITE(taitosj_collision_reg_clear_w) + AM_RANGE(0xd509, 0xd50a) AM_MIRROR(0x00f0) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_gfxpointer) + AM_RANGE(0xd50b, 0xd50b) AM_MIRROR(0x00f0) AM_WRITE(taitosj_soundcommand_w) + AM_RANGE(0xd50d, 0xd50d) AM_MIRROR(0x00f0) AM_WRITE(MWA8_RAM) /*watchdog_reset_w*/ /* Bio Attack sometimes resets after you die */ + AM_RANGE(0xd50e, 0xd50e) AM_MIRROR(0x00f0) AM_WRITE(taitosj_bankswitch_w) + AM_RANGE(0xd50f, 0xd50f) AM_MIRROR(0x00f0) AM_WRITE(MWA8_NOP) + AM_RANGE(0xd600, 0xd600) AM_MIRROR(0x00ff) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_video_mode) + AM_RANGE(0xd700, 0xdfff) AM_NOP + AM_RANGE(0xe000, 0xffff) AM_ROM ADDRESS_MAP_END -/* seems the most logical way to do the gears */ -static UINT8 kikstart_gearP1; -static UINT8 kikstart_gearP2; -static READ8_HANDLER ( kikstart_gearsP1_read ) -{ - /* gear MUST be 1, 2 or 3 */ - - int portreturn = readinputportbytag("IN3") & 0xf4; - if (readinputportbytag("FAKE") & 0x01) kikstart_gearP1 = 1; - if (readinputportbytag("FAKE") & 0x02) kikstart_gearP1 = 2; - if (readinputportbytag("FAKE") & 0x04) kikstart_gearP1 = 3; - - if (kikstart_gearP1 == 1) portreturn |= (0x02); - if (kikstart_gearP1 == 2) portreturn |= (0x03); - if (kikstart_gearP1 == 3) portreturn |= (0x01); - -//popmessage ("Kikstart gear %02x", kikstart_gear); -//Is there a more attractive way to display this mid game? - return portreturn; -} +/* seems the most logical way to do the gears */ +static UINT8 kikstart_gears[2]; -static READ8_HANDLER ( kikstart_gearsP2_read ) +static int kikstart_gear_r(void *param) { - /* gear MUST be 1, 2 or 3 */ + const char *port_tag; - int portreturn = readinputportbytag("IN4") & 0xf4; + int player = (int)param; - if (readinputportbytag("FAKE") & 0x08) kikstart_gearP2 = 1; - if (readinputportbytag("FAKE") & 0x10) kikstart_gearP2 = 2; - if (readinputportbytag("FAKE") & 0x20) kikstart_gearP2 = 3; + if (player == 0) + port_tag = "GEARP1"; + else + port_tag = "GEARP2"; - if (kikstart_gearP2 == 1) portreturn |= (0x02); - if (kikstart_gearP2 == 2) portreturn |= (0x03); - if (kikstart_gearP2 == 3) portreturn |= (0x01); + /* gear MUST be 1, 2 or 3 */ + if (readinputportbytag(port_tag) & 0x01) kikstart_gears[player] = 0x02; + if (readinputportbytag(port_tag) & 0x02) kikstart_gears[player] = 0x03; + if (readinputportbytag(port_tag) & 0x04) kikstart_gears[player] = 0x01; -//popmessage ("Kikstart gear %02x", kikstart_gear); -//Is there a more attractive way to display this mid game? - return portreturn; + return kikstart_gears[player]; } -static ADDRESS_MAP_START( kikstart_readmem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x5fff) AM_READ(MRA8_ROM) - AM_RANGE(0x6000, 0x7fff) AM_READ(MRA8_BANK1) - AM_RANGE(0x8000, 0x87ff) AM_READ(MRA8_RAM) - AM_RANGE(0x8800, 0x8800) AM_READ(taitosj_mcu_data_r) - AM_RANGE(0x8801, 0x8801) AM_READ(taitosj_mcu_status_r) - AM_RANGE(0x8802, 0x8802) AM_READ(MRA8_NOP) - AM_RANGE(0xc000, 0xd05f) AM_READ(MRA8_RAM) - AM_RANGE(0xd100, 0xd1ff) AM_READ(MRA8_RAM) - AM_RANGE(0xd400, 0xd403) AM_READ(taitosj_collision_reg_r) - AM_RANGE(0xd404, 0xd404) AM_READ(taitosj_gfxrom_r) - AM_RANGE(0xd408, 0xd408) AM_READ(input_port_0_r) /* IN0 */ - AM_RANGE(0xd409, 0xd409) AM_READ(input_port_1_r) /* IN1 */ - AM_RANGE(0xd40a, 0xd40a) AM_READ(input_port_5_r) /* DSW1 */ - AM_RANGE(0xd40b, 0xd40b) AM_READ(input_port_2_r) /* IN2 */ - AM_RANGE(0xd40c, 0xd40c) AM_READ(kikstart_gearsP1_read) /* IN3 */ - AM_RANGE(0xd40d, 0xd40d) AM_READ(kikstart_gearsP2_read) /* IN4 */ - AM_RANGE(0xd40f, 0xd40f) AM_READ(AY8910_read_port_0_r) /* DSW2 and DSW3 */ - AM_RANGE(0xd800, 0xdfff) AM_READ(MRA8_RAM) - AM_RANGE(0xe000, 0xefff) AM_READ(MRA8_ROM) -ADDRESS_MAP_END -static ADDRESS_MAP_START( kikstart_writemem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x7fff) AM_WRITE(MWA8_ROM) - AM_RANGE(0x8000, 0x87ff) AM_WRITE(MWA8_RAM) - AM_RANGE(0x8800, 0x8800) AM_WRITE(taitosj_mcu_data_w) - AM_RANGE(0x8802, 0x8802) AM_WRITE(MWA8_NOP) - AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE(&taitosj_characterram) - AM_RANGE(0xc000, 0xc3ff) AM_WRITE(MWA8_RAM) - AM_RANGE(0xc400, 0xc7ff) AM_WRITE(videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size) - AM_RANGE(0xc800, 0xcbff) AM_WRITE(taitosj_videoram2_w) AM_BASE(&taitosj_videoram2) - AM_RANGE(0xcc00, 0xcfff) AM_WRITE(taitosj_videoram3_w) AM_BASE(&taitosj_videoram3) +static ADDRESS_MAP_START( kikstart_main_map, ADDRESS_SPACE_PROGRAM, 8 ) + AM_RANGE(0x0000, 0x5fff) AM_ROM + AM_RANGE(0x6000, 0x7fff) AM_READWRITE(MRA8_BANK1, MWA8_ROM) + AM_RANGE(0x8000, 0x87ff) AM_RAM + AM_RANGE(0x8800, 0x8800) AM_READWRITE(taitosj_mcu_data_r, taitosj_mcu_data_w) + AM_RANGE(0x8801, 0x8801) AM_READ(taitosj_mcu_status_r) + AM_RANGE(0x8802, 0x8802) AM_READWRITE(MRA8_NOP, MWA8_NOP) AM_RANGE(0x8a00, 0x8a5f) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_colscrolly) - AM_RANGE(0xd100, 0xd17f) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size) - AM_RANGE(0xd180, 0xd1ff) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram_2) AM_SIZE(&spriteram_2_size) - AM_RANGE(0xd200, 0xd27f) AM_WRITE(taitosj_paletteram_w) AM_BASE(&paletteram) + AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE(&taitosj_characterram) + AM_RANGE(0xc000, 0xc3ff) AM_RAM + AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE(&taitosj_videoram_1) + AM_RANGE(0xc800, 0xcbff) AM_RAM AM_BASE(&taitosj_videoram_2) + AM_RANGE(0xcc00, 0xcfff) AM_RAM AM_BASE(&taitosj_videoram_3) + AM_RANGE(0xd000, 0xd001) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_colorbank) + AM_RANGE(0xd002, 0xd007) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_scroll) + AM_RANGE(0xd100, 0xd1ff) AM_RAM AM_BASE(&taitosj_spriteram) + AM_RANGE(0xd200, 0xd27f) AM_RAM AM_BASE(&taitosj_paletteram) AM_RANGE(0xd300, 0xd300) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_video_priority) + AM_RANGE(0xd400, 0xd403) AM_READ(MRA8_RAM) AM_BASE(&taitosj_collision_reg) + AM_RANGE(0xd404, 0xd404) AM_READ(taitosj_gfxrom_r) + AM_RANGE(0xd408, 0xd408) AM_READ(input_port_0_r) /* IN0 */ + AM_RANGE(0xd409, 0xd409) AM_READ(input_port_1_r) /* IN1 */ + AM_RANGE(0xd40a, 0xd40a) AM_READ(input_port_5_r) /* DSW1 */ + AM_RANGE(0xd40b, 0xd40b) AM_READ(input_port_2_r) /* IN2 */ + AM_RANGE(0xd40c, 0xd40c) AM_READ(input_port_3_r) /* IN3 */ + AM_RANGE(0xd40d, 0xd40d) AM_READ(input_port_4_r) /* IN4 */ AM_RANGE(0xd40e, 0xd40e) AM_WRITE(AY8910_control_port_0_w) - AM_RANGE(0xd40f, 0xd40f) AM_WRITE(AY8910_write_port_0_w) - AM_RANGE(0xd000, 0xd001) AM_WRITE(taitosj_colorbank_w) AM_BASE(&taitosj_colorbank) - AM_RANGE(0xd002, 0xd007) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_scroll) + AM_RANGE(0xd40f, 0xd40f) AM_READWRITE(AY8910_read_port_0_r, AY8910_write_port_0_w) /* DSW2 and DSW3 */ AM_RANGE(0xd508, 0xd508) AM_WRITE(taitosj_collision_reg_clear_w) AM_RANGE(0xd509, 0xd50a) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_gfxpointer) AM_RANGE(0xd50b, 0xd50b) AM_WRITE(taitosj_soundcommand_w) AM_RANGE(0xd50d, 0xd50d) AM_WRITE(watchdog_reset_w) AM_RANGE(0xd50e, 0xd50e) AM_WRITE(taitosj_bankswitch_w) - AM_RANGE(0xd600, 0xd600) AM_WRITE(taitosj_videoenable_w) - AM_RANGE(0xd800, 0xdfff) AM_WRITE(MWA8_RAM) AM_BASE(&kikstart_scrollram)// scroll ram + ??? - AM_RANGE(0xe000, 0xefff) AM_WRITE(MWA8_ROM) + AM_RANGE(0xd600, 0xd600) AM_WRITE(MWA8_RAM) AM_BASE(&taitosj_video_mode) + AM_RANGE(0xd800, 0xdfff) AM_RAM AM_BASE(&kikstart_scrollram)// scroll ram + ??? + AM_RANGE(0xe000, 0xefff) AM_ROM ADDRESS_MAP_END -static ADDRESS_MAP_START( sound_readmem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x3fff) AM_READ(MRA8_ROM) - AM_RANGE(0x4000, 0x43ff) AM_READ(MRA8_RAM) - AM_RANGE(0x4801, 0x4801) AM_READ(AY8910_read_port_1_r) - AM_RANGE(0x4803, 0x4803) AM_READ(AY8910_read_port_2_r) - AM_RANGE(0x4805, 0x4805) AM_READ(AY8910_read_port_3_r) - AM_RANGE(0x5000, 0x5000) AM_READ(soundlatch_r) - AM_RANGE(0xe000, 0xefff) AM_READ(MRA8_ROM) /* space for diagnostic ROM */ -ADDRESS_MAP_END -static ADDRESS_MAP_START( sound_writemem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x3fff) AM_WRITE(MWA8_ROM) - AM_RANGE(0x4000, 0x43ff) AM_WRITE(MWA8_RAM) +static ADDRESS_MAP_START( taitosj_audio_map, ADDRESS_SPACE_PROGRAM, 8 ) + AM_RANGE(0x0000, 0x3fff) AM_ROM + AM_RANGE(0x4000, 0x43ff) AM_RAM AM_RANGE(0x4800, 0x4800) AM_WRITE(AY8910_control_port_1_w) - AM_RANGE(0x4801, 0x4801) AM_WRITE(AY8910_write_port_1_w) + AM_RANGE(0x4801, 0x4801) AM_READWRITE(AY8910_read_port_1_r, AY8910_write_port_1_w) AM_RANGE(0x4802, 0x4802) AM_WRITE(AY8910_control_port_2_w) - AM_RANGE(0x4803, 0x4803) AM_WRITE(AY8910_write_port_2_w) + AM_RANGE(0x4803, 0x4803) AM_READWRITE(AY8910_read_port_2_r, AY8910_write_port_2_w) AM_RANGE(0x4804, 0x4804) AM_WRITE(AY8910_control_port_3_w) - AM_RANGE(0x4805, 0x4805) AM_WRITE(AY8910_write_port_3_w) - AM_RANGE(0xe000, 0xefff) AM_WRITE(MWA8_ROM) + AM_RANGE(0x4805, 0x4805) AM_READWRITE(AY8910_read_port_3_r, AY8910_write_port_3_w) + AM_RANGE(0x5000, 0x5000) AM_READ(soundlatch_r) + AM_RANGE(0xe000, 0xefff) AM_ROM /* space for diagnostic ROM */ ADDRESS_MAP_END -static ADDRESS_MAP_START( m68705_readmem, ADDRESS_SPACE_PROGRAM, 8 ) +static ADDRESS_MAP_START( taitosj_mcu_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_FLAGS( AMEF_ABITS(11) ) - AM_RANGE(0x0000, 0x0000) AM_READ(taitosj_68705_portA_r) - AM_RANGE(0x0001, 0x0001) AM_READ(taitosj_68705_portB_r) + AM_RANGE(0x0000, 0x0000) AM_READWRITE(taitosj_68705_portA_r, taitosj_68705_portA_w) + AM_RANGE(0x0001, 0x0001) AM_READWRITE(taitosj_68705_portB_r, taitosj_68705_portB_w) AM_RANGE(0x0002, 0x0002) AM_READ(taitosj_68705_portC_r) - AM_RANGE(0x0003, 0x007f) AM_READ(MRA8_RAM) - AM_RANGE(0x0080, 0x07ff) AM_READ(MRA8_ROM) + AM_RANGE(0x0003, 0x007f) AM_RAM + AM_RANGE(0x0080, 0x07ff) AM_ROM ADDRESS_MAP_END -static ADDRESS_MAP_START( m68705_writemem, ADDRESS_SPACE_PROGRAM, 8 ) - ADDRESS_MAP_FLAGS( AMEF_ABITS(11) ) - AM_RANGE(0x0000, 0x0000) AM_WRITE(taitosj_68705_portA_w) - AM_RANGE(0x0001, 0x0001) AM_WRITE(taitosj_68705_portB_w) - AM_RANGE(0x0003, 0x007f) AM_WRITE(MWA8_RAM) - AM_RANGE(0x0080, 0x07ff) AM_WRITE(MWA8_ROM) -ADDRESS_MAP_END + #define DSW2_PORT \ PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_A ) ) \ @@ -589,14 +530,17 @@ ADDRESS_MAP_END static INPUT_PORTS_START( spaceskr ) -COMMON_IN0 -COMMON_IN1 -COMMON_IN2 -COMMON_IN3(IP_ACTIVE_HIGH) + COMMON_IN0 + + COMMON_IN1 + + COMMON_IN2 + + COMMON_IN3(IP_ACTIVE_HIGH) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) @@ -672,12 +616,13 @@ static INPUT_PORTS_START( spacecr ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) -COMMON_IN2 -COMMON_IN3(IP_ACTIVE_LOW) + COMMON_IN2 + + COMMON_IN3(IP_ACTIVE_LOW) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) @@ -755,12 +700,13 @@ static INPUT_PORTS_START( junglek ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) -COMMON_IN2 -COMMON_IN3(IP_ACTIVE_HIGH) + COMMON_IN2 + + COMMON_IN3(IP_ACTIVE_HIGH) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x03, 0x03, "Finish Bonus" ) @@ -814,14 +760,17 @@ COMMON_IN3(IP_ACTIVE_HIGH) INPUT_PORTS_END static INPUT_PORTS_START( piratpet ) -COMMON_IN0 -COMMON_IN1 //Button 2 skips levels when Debug mode is on -COMMON_IN2 -COMMON_IN3(IP_ACTIVE_HIGH) + COMMON_IN0 + + COMMON_IN1 //Button 2 skips levels when Debug mode is on + + COMMON_IN2 + + COMMON_IN3(IP_ACTIVE_HIGH) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x03, 0x03, "Finish Bonus" ) @@ -906,7 +855,7 @@ static INPUT_PORTS_START( alpine ) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x03, 0x03, "Jump Bonus" ) @@ -987,11 +936,11 @@ static INPUT_PORTS_START( alpinea ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) -COMMON_IN3(IP_ACTIVE_LOW) //Tilt flips screen + COMMON_IN3(IP_ACTIVE_LOW) //Tilt flips screen PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x03, 0x03, "Jump Bonus" ) @@ -1063,12 +1012,13 @@ static INPUT_PORTS_START( timetunl ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) -COMMON_IN2 -COMMON_IN3(IP_ACTIVE_LOW) + COMMON_IN2 + + COMMON_IN3(IP_ACTIVE_LOW) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) @@ -1126,7 +1076,7 @@ COMMON_IN3(IP_ACTIVE_LOW) INPUT_PORTS_END static INPUT_PORTS_START( wwestern ) -WWEST_INPUT1 + WWEST_INPUT1 PORT_START_TAG("IN2") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN2 ) @@ -1136,7 +1086,7 @@ WWEST_INPUT1 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) -WWEST_INPUT2 + WWEST_INPUT2 PORT_START_TAG("DSW1") PORT_DIPNAME( 0x03, 0x03, DEF_STR( Bonus_Life ) ) @@ -1191,7 +1141,7 @@ WWEST_INPUT2 INPUT_PORTS_END static INPUT_PORTS_START( frontlin ) -WWEST_INPUT1 + WWEST_INPUT1 PORT_START_TAG("IN2") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) @@ -1203,7 +1153,7 @@ WWEST_INPUT1 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) -WWEST_INPUT2 + WWEST_INPUT2 PORT_START_TAG("DSW1") PORT_DIPNAME( 0x03, 0x03, DEF_STR( Bonus_Life ) ) @@ -1258,14 +1208,17 @@ WWEST_INPUT2 INPUT_PORTS_END static INPUT_PORTS_START( elevator ) -COMMON_IN0 -COMMON_IN1 -COMMON_IN2 -COMMON_IN3(IP_ACTIVE_HIGH) + COMMON_IN0 + + COMMON_IN1 + + COMMON_IN2 + + COMMON_IN3(IP_ACTIVE_HIGH) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x03, 0x03, DEF_STR( Bonus_Life ) ) @@ -1321,7 +1274,7 @@ COMMON_IN3(IP_ACTIVE_HIGH) INPUT_PORTS_END static INPUT_PORTS_START( tinstar ) -WWEST_INPUT1 + WWEST_INPUT1 PORT_START_TAG("IN2") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) @@ -1348,7 +1301,7 @@ WWEST_INPUT1 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT ) PORT_8WAY PORT_COCKTAIL PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN ) PORT_8WAY PORT_COCKTAIL PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x03, 0x03, "Bonus Life?" ) @@ -1425,12 +1378,13 @@ static INPUT_PORTS_START( waterski ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) -COMMON_IN2 -COMMON_IN3(IP_ACTIVE_HIGH) + COMMON_IN2 + + COMMON_IN3(IP_ACTIVE_HIGH) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) @@ -1515,11 +1469,11 @@ static INPUT_PORTS_START( bioatack ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) -COMMON_IN3(IP_ACTIVE_LOW) + COMMON_IN3(IP_ACTIVE_LOW) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") /* d50a */ PORT_DIPNAME( 0x03, 0x03, DEF_STR( Bonus_Life ) ) @@ -1576,14 +1530,17 @@ COMMON_IN3(IP_ACTIVE_LOW) INPUT_PORTS_END static INPUT_PORTS_START( sfposeid ) -COMMON_IN0 -COMMON_IN1 -COMMON_IN2 -COMMON_IN3(IP_ACTIVE_HIGH) + COMMON_IN0 + + COMMON_IN1 + + COMMON_IN2 + + COMMON_IN3(IP_ACTIVE_HIGH) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) @@ -1641,14 +1598,17 @@ COMMON_IN3(IP_ACTIVE_HIGH) INPUT_PORTS_END static INPUT_PORTS_START( hwrace ) -COMMON_IN0 -COMMON_IN1 -COMMON_IN2 -COMMON_IN3(IP_ACTIVE_HIGH) + COMMON_IN0 + + COMMON_IN1 + + COMMON_IN2 + + COMMON_IN3(IP_ACTIVE_HIGH) PORT_START_TAG("IN4") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) // from sound CPU + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(input_port_4_f0_r, 0) // from sound CPU PORT_START_TAG("DSW1") PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) @@ -1725,20 +1685,19 @@ static INPUT_PORTS_START( kikstart ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) PORT_START_TAG("IN3") /* Service */ - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SPECIAL ) // gear - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL ) // gear + PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(kikstart_gear_r, (void *)0) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SPECIAL ) // gear + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* needs to be 0, otherwise cannot shift */ PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START_TAG("IN4") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SPECIAL ) // gear - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL ) // gear + PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(kikstart_gear_r, (void *)1) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SPECIAL ) // gear + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* needs to be 0, otherwise cannot shift */ + PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START_TAG("DSW1") PORT_DIPNAME(0x03, 0x01, "Gate Bonus" ) @@ -1783,13 +1742,15 @@ static INPUT_PORTS_START( kikstart ) PORT_DIPSETTING( 0x00, "A only" ) /* fake for handling the gears */ - PORT_START_TAG("FAKE") + PORT_START_TAG("GEARP1") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 1st Gear") PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 2nd Gear") PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 3rd Gear") - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 1st Gear") PORT_COCKTAIL - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 2nd Gear") PORT_COCKTAIL - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 3rd Gear") PORT_COCKTAIL + + PORT_START_TAG("GEARP2") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 1st Gear") PORT_COCKTAIL + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 2nd Gear") PORT_COCKTAIL + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 3rd Gear") PORT_COCKTAIL INPUT_PORTS_END @@ -1873,7 +1834,7 @@ static const struct AY8910interface ay8910_interface_2 = { 0, 0, - dac_out_w, /* port Awrite */ + dac_out_w, /* port Awrite */ dac_vol_w /* port Bwrite */ }; @@ -1881,7 +1842,7 @@ static const struct AY8910interface ay8910_interface_3 = { 0, 0, - in5_w, + input_port_4_f0_w, 0 }; @@ -1899,12 +1860,12 @@ static MACHINE_DRIVER_START( nomcu ) /* basic machine hardware */ MDRV_CPU_ADD_TAG("main",Z80,8000000/2) /* 4 MHz */ - MDRV_CPU_PROGRAM_MAP(readmem,writemem) + MDRV_CPU_PROGRAM_MAP(taitosj_main_nomcu_map,0) MDRV_CPU_VBLANK_INT(irq0_line_hold,1) - MDRV_CPU_ADD(Z80,6000000/2) /* audio CPU */ /* 3 MHz */ - MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem) + MDRV_CPU_ADD(Z80,6000000/2) + MDRV_CPU_PROGRAM_MAP(taitosj_audio_map,0) /* interrupts: */ /* - no interrupts synced with vblank */ /* - NMI triggered by the main CPU */ @@ -1960,24 +1921,25 @@ static MACHINE_DRIVER_START( mcu ) /* basic machine hardware */ MDRV_IMPORT_FROM(nomcu) MDRV_CPU_MODIFY("main") - MDRV_CPU_PROGRAM_MAP(mcu_readmem,mcu_writemem) + MDRV_CPU_PROGRAM_MAP(taitosj_main_mcu_map,0) MDRV_CPU_ADD(M68705,3000000/M68705_CLOCK_DIVIDER) /* xtal is 3MHz, divided by 4 internally */ - MDRV_CPU_PROGRAM_MAP(m68705_readmem,m68705_writemem) + MDRV_CPU_PROGRAM_MAP(taitosj_mcu_map,0) MACHINE_DRIVER_END + static MACHINE_DRIVER_START( kikstart ) /* basic machine hardware */ - MDRV_IMPORT_FROM(nomcu) + MDRV_IMPORT_FROM(mcu) MDRV_CPU_MODIFY("main") - MDRV_CPU_PROGRAM_MAP(kikstart_readmem,kikstart_writemem) + MDRV_CPU_PROGRAM_MAP(kikstart_main_map,0) - MDRV_CPU_ADD(M68705,3000000/M68705_CLOCK_DIVIDER) /* xtal is 3MHz, divided by 4 internally */ - MDRV_CPU_PROGRAM_MAP(m68705_readmem,m68705_writemem) + MDRV_VIDEO_UPDATE(kikstart) MACHINE_DRIVER_END + /*************************************************************************** Game driver(s) @@ -2673,16 +2635,16 @@ static DRIVER_INIT( junglhbr ) static DRIVER_INIT( kikstart ) { - kikstart_gearP1 = 1; - kikstart_gearP2 = 1; + /* start in 1st gear */ + kikstart_gears[0] = 0x02; + kikstart_gears[1] = 0x02; } void taitosj_register_main_savestate(void) { state_save_register_global(sndnmi_disable); - state_save_register_global(in5); - state_save_register_global(kikstart_gearP1); - state_save_register_global(kikstart_gearP2); + state_save_register_global(input_port_4_f0); + state_save_register_global_array(kikstart_gears); state_save_register_global(dac_out); state_save_register_global(dac_vol); } diff --git a/src/mame/video/taitosj.c b/src/mame/video/taitosj.c index 4d69c1b1a5f..177da7a6013 100644 --- a/src/mame/video/taitosj.c +++ b/src/mame/video/taitosj.c @@ -8,38 +8,43 @@ #include "driver.h" -#ifndef MIN -#define MIN(x,y) (x)<(y)?(x):(y) -#endif +#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) -UINT8 *taitosj_videoram2,*taitosj_videoram3; + +UINT8 *taitosj_videoram_1; +UINT8 *taitosj_videoram_2; +UINT8 *taitosj_videoram_3; +UINT8 *taitosj_spriteram; +UINT8 *taitosj_paletteram; UINT8 *taitosj_characterram; UINT8 *taitosj_scroll; UINT8 *taitosj_colscrolly; UINT8 *taitosj_gfxpointer; -UINT8 *taitosj_colorbank,*taitosj_video_priority; +UINT8 *taitosj_colorbank; +UINT8 *taitosj_video_mode; +UINT8 *taitosj_video_priority; +UINT8 *taitosj_collision_reg; UINT8 *kikstart_scrollram; -static UINT8 *taitosj_spritebank; -static UINT8 taitosj_collision_reg[4]; -static UINT8 *dirtybuffer2,*dirtybuffer3; -static mame_bitmap *taitosj_tmpbitmap[3]; +static mame_bitmap *taitosj_layer_bitmap[3]; static mame_bitmap *sprite_sprite_collbitmap1,*sprite_sprite_collbitmap2; -static mame_bitmap *sprite_plane_collbitmap1; -static mame_bitmap *sprite_plane_collbitmap2[3]; +static mame_bitmap *sprite_layer_collbitmap1; +static mame_bitmap *sprite_layer_collbitmap2[3]; static UINT8 dirtycharacter1[256],dirtycharacter2[256]; static UINT8 dirtysprite1[64],dirtysprite2[64]; -static UINT8 taitosj_video_enable; -static UINT8 flipscreen[2]; -static rectangle spritearea[32]; /*areas on bitmap (sprite locations)*/ -static UINT8 spriteon[32]; /* 1 if sprite is active */ -static const int playfield_enable_mask[3] = { 0x10, 0x20, 0x40 }; +static const int layer_enable_mask[3] = { 0x10, 0x20, 0x40 }; + +typedef void (*copy_layer_func_t)(running_machine *, mame_bitmap *, + const rectangle *, int, int *, rectangle *); /*************************************************************************** - I call the three planes with the conventional names "front", "middle" and + I call the three layers with the conventional names "front", "middle" and "back", because that's their default order, but they can be arranged, together with the sprites, in any order. The priority is selected by register 0xd300, which works as follow: @@ -47,9 +52,9 @@ static const int playfield_enable_mask[3] = { 0x10, 0x20, 0x40 }; bits 0-3 go to A4-A7 of a 256x4 PROM bit 4 selects D0/D1 or D2/D3 of the PROM bit 5-7 n.c. - A0-A3 of the PROM is fed with a mask of the inactive planes + A0-A3 of the PROM is fed with a mask of the inactive layers (i.e. all-zero) in the order sprites-front-middle-back - the 2-bit code which comes out from the PROM selects the plane + the 2-bit code which comes out from the PROM selects the layer to display. Here is a dump of one of these PROMs; on the right is the resulting order @@ -109,28 +114,32 @@ PALETTE_INIT( taitosj ) #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) /* all gfx elements use the same palette */ - for (i = 0;i < 64;i++) + for (i = 0 ;i < 64; i++) { - COLOR(0,i) = i; /* we create both a "normal" lookup table and one where pen 0 is */ /* always mapped to color 0. This is needed for transparency. */ - if (i % 8 == 0) COLOR(0,i + 64) = 0; - else COLOR(0,i + 64) = i; - } + 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++) + + for (i = 0; i < 32; i++) { - int j,mask; + 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--) + for (j = 3; j >= 0; j--) { int data; @@ -145,45 +154,44 @@ PALETTE_INIT( taitosj ) } - -WRITE8_HANDLER( taitosj_paletteram_w ) +static void set_colors(running_machine *machine) { - int bit0,bit1,bit2; - int r,g,b,val; - - - paletteram[offset] = data; - - /* red component */ - val = paletteram[offset | 1]; - bit0 = (~val >> 6) & 0x01; - bit1 = (~val >> 7) & 0x01; - val = paletteram[offset & ~1]; - bit2 = (~val >> 0) & 0x01; - r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - - /* green component */ - val = paletteram[offset | 1]; - bit0 = (~val >> 3) & 0x01; - bit1 = (~val >> 4) & 0x01; - bit2 = (~val >> 5) & 0x01; - g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - - /* blue component */ - val = paletteram[offset | 1]; - bit0 = (~val >> 0) & 0x01; - bit1 = (~val >> 1) & 0x01; - bit2 = (~val >> 2) & 0x01; - b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - - palette_set_color(Machine,offset / 2,MAKE_RGB(r,g,b)); + offs_t offs; + + for (offs = 0; offs < 0x40; offs++) + { + int bit0,bit1,bit2; + int r,g,b,val; + + /* red component */ + val = taitosj_paletteram[(offs << 1) | 0x01]; + bit0 = (~val >> 6) & 0x01; + bit1 = (~val >> 7) & 0x01; + val = taitosj_paletteram[(offs << 1) | 0x00]; + bit2 = (~val >> 0) & 0x01; + r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + + /* green component */ + val = taitosj_paletteram[(offs << 1) | 0x01]; + bit0 = (~val >> 3) & 0x01; + bit1 = (~val >> 4) & 0x01; + bit2 = (~val >> 5) & 0x01; + g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + + /* blue component */ + val = taitosj_paletteram[(offs << 1) | 0x01]; + bit0 = (~val >> 0) & 0x01; + bit1 = (~val >> 1) & 0x01; + bit2 = (~val >> 2) & 0x01; + b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + + palette_set_color(machine, offs, MAKE_RGB(r,g,b)); + } } + static void taitosj_postload(void) { - memset(dirtybuffer, 1, videoram_size); - memset(dirtybuffer2, 1, videoram_size); - memset(dirtybuffer3, 1, videoram_size); memset(dirtycharacter1, 1, sizeof(dirtycharacter1)); memset(dirtycharacter2, 1, sizeof(dirtycharacter2)); memset(dirtysprite1, 1, sizeof(dirtysprite1)); @@ -199,133 +207,44 @@ VIDEO_START( taitosj ) { int i; - - taitosj_tmpbitmap[0] = taitosj_tmpbitmap[1] = taitosj_tmpbitmap[2] = 0; - sprite_sprite_collbitmap2 = sprite_sprite_collbitmap1 = 0; - sprite_plane_collbitmap1 = 0; - sprite_plane_collbitmap2[0] = sprite_plane_collbitmap2[1] = sprite_plane_collbitmap2[2] = 0; - dirtybuffer3 = dirtybuffer2 = 0; - - - video_start_generic(machine); - - dirtybuffer2 = auto_malloc(videoram_size); - memset(dirtybuffer2,1,videoram_size); - - dirtybuffer3 = auto_malloc(videoram_size); - memset(dirtybuffer3,1,videoram_size); - - sprite_plane_collbitmap1 = auto_bitmap_alloc(16,16,machine->screen[0].format); + sprite_layer_collbitmap1 = auto_bitmap_alloc(16,16,machine->screen[0].format); for (i = 0; i < 3; i++) { - taitosj_tmpbitmap[i] = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format); - - sprite_plane_collbitmap2[i] = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format); + taitosj_layer_bitmap[i] = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format); + sprite_layer_collbitmap2[i] = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format); } sprite_sprite_collbitmap1 = auto_bitmap_alloc(32,32,machine->screen[0].format); sprite_sprite_collbitmap2 = auto_bitmap_alloc(32,32,machine->screen[0].format); - flipscreen[0] = flipscreen[1] = 0; - - taitosj_spritebank = spriteram; - memset(dirtycharacter1, 1, sizeof(dirtycharacter1)); memset(dirtycharacter2, 1, sizeof(dirtycharacter2)); memset(dirtysprite1, 1, sizeof(dirtysprite1)); memset(dirtysprite2, 1, sizeof(dirtysprite2)); state_save_register_func_postload(taitosj_postload); - state_save_register_global_array(taitosj_collision_reg); - state_save_register_global(taitosj_video_enable); - state_save_register_global_array(flipscreen); } READ8_HANDLER( taitosj_gfxrom_r ) { - int offs; + UINT8 ret; - - offs = taitosj_gfxpointer[0]+taitosj_gfxpointer[1]*256; - - taitosj_gfxpointer[0]++; - if (taitosj_gfxpointer[0] == 0) taitosj_gfxpointer[1]++; + offs_t offs = taitosj_gfxpointer[0] | (taitosj_gfxpointer[1] << 8); if (offs < 0x8000) - return memory_region(REGION_GFX1)[offs]; - else return 0; -} - - -WRITE8_HANDLER( taitosj_videoram2_w ) -{ - if (taitosj_videoram2[offset] != data) - { - dirtybuffer2[offset] = 1; - - taitosj_videoram2[offset] = data; - } -} - - - -WRITE8_HANDLER( taitosj_videoram3_w ) -{ - if (taitosj_videoram3[offset] != data) - { - dirtybuffer3[offset] = 1; - - taitosj_videoram3[offset] = data; - } -} - - - -WRITE8_HANDLER( taitosj_colorbank_w ) -{ - if (taitosj_colorbank[offset] != data) - { -logerror("colorbank %d = %02x\n",offset,data); - memset(dirtybuffer,1,videoram_size); - memset(dirtybuffer2,1,videoram_size); - memset(dirtybuffer3,1,videoram_size); - - taitosj_colorbank[offset] = data; - } -} - - - -WRITE8_HANDLER( taitosj_videoenable_w ) -{ - if (taitosj_video_enable != data) - { -logerror("videoenable = %02x\n",data); - - if ((taitosj_video_enable & 3) != (data & 3)) - { - flipscreen[0] = data & 1; - flipscreen[1] = data & 2; - - memset(dirtybuffer,1,videoram_size); - memset(dirtybuffer2,1,videoram_size); - memset(dirtybuffer3,1,videoram_size); - } + ret = memory_region(REGION_GFX1)[offs]; + else + ret = 0; - //OBJEX sprite bank select - if( data & 4 ) - taitosj_spritebank = spriteram_2; - else - taitosj_spritebank = spriteram; + offs = offs + 1; - if ((taitosj_video_enable & 4) != (data & 4)) - logerror( "sprite bank[%d]\n", (data & 4) >> 2 ); + taitosj_gfxpointer[0] = offs & 0xff; + taitosj_gfxpointer[1] = offs >> 8; - taitosj_video_enable = data; - } + return ret; } @@ -354,16 +273,6 @@ WRITE8_HANDLER( junglhbr_characterram_w ) taitosj_characterram_w(offset, data ^ 0xfc); } -/*************************************************************************** - - As if the hardware weren't complicated enough, it also has built-in - collision detection. - -***************************************************************************/ -READ8_HANDLER( taitosj_collision_reg_r ) -{ - return taitosj_collision_reg[offset]; -} WRITE8_HANDLER( taitosj_collision_reg_clear_w ) { @@ -373,24 +282,34 @@ WRITE8_HANDLER( taitosj_collision_reg_clear_w ) taitosj_collision_reg[3] = 0; } -INLINE int get_sprite_xy(UINT8 num, UINT8* sx, UINT8* sy) + +INLINE int get_sprite_xy(UINT8 which, UINT8* sx, UINT8* sy) { - int offs = num * 4; + offs_t offs = which * 4; + *sx = taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 0]; + *sy = 240 - taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 1]; - *sx = taitosj_spritebank[offs] - 1; - *sy = 240 - taitosj_spritebank[offs + 1]; return (*sy < 240); } +INLINE const gfx_element *get_sprite_gfx_element(running_machine *machine, UINT8 which) +{ + offs_t offs = which * 4; + + return machine->gfx[(taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x40) ? 3 : 1]; +} + + static int check_sprite_sprite_bitpattern(running_machine *machine, - int sx1, int sy1, int num1, - int sx2, int sy2, int num2) + int sx1, int sy1, int which1, + int sx2, int sy2, int which2) { - int x,y,minx,miny,maxx = 16,maxy = 16; - int offs1 = num1 * 4; - int offs2 = num2 * 4; + int x, y, minx, miny, maxx = 16, maxy = 16; + + offs_t offs1 = which1 * 4; + offs_t offs2 = which2 * 4; /* normalize coordinates to (0,0) and compute overlap */ if (sx1 < sx2) @@ -420,23 +339,25 @@ static int check_sprite_sprite_bitpattern(running_machine *machine, } /* draw the sprites into seperate bitmaps and check overlapping region */ - drawgfx(sprite_sprite_collbitmap1,machine->gfx[(taitosj_spritebank[offs1 + 3] & 0x40) ? 3 : 1], - taitosj_spritebank[offs1 + 3] & 0x3f, + drawgfx(sprite_sprite_collbitmap1, get_sprite_gfx_element(machine, which1), + taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 3] & 0x3f, 0, - taitosj_spritebank[offs1 + 2] & 1, taitosj_spritebank[offs1 + 2] & 2, - sx1,sy1, - 0,TRANSPARENCY_NONE,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); - drawgfx(sprite_sprite_collbitmap2,machine->gfx[(taitosj_spritebank[offs2 + 3] & 0x40) ? 3 : 1], - taitosj_spritebank[offs2 + 3] & 0x3f, + drawgfx(sprite_sprite_collbitmap2, get_sprite_gfx_element(machine, which2), + taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 3] & 0x3f, 0, - taitosj_spritebank[offs2 + 2] & 1, taitosj_spritebank[offs2 + 2] & 2, - sx2,sy2, - 0,TRANSPARENCY_NONE,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); - for (y = miny;y < maxy;y++) + for (y = miny; y < maxy; y++) { - for(x = minx;x < maxx;x++) + 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])) @@ -452,54 +373,55 @@ static int check_sprite_sprite_bitpattern(running_machine *machine, static void check_sprite_sprite_collision(running_machine *machine) { - UINT8 i,j,sx1,sx2,sy1,sy2; - - - if (taitosj_video_enable & 0x80) // check OBJOFF + if (SPRITES_ON) { + int which1; + /* chech each pair of sprites */ - for (i = 0x00; i < 0x20; i++) + for (which1 = 0; which1 < 0x20; which1++) { - if ((i >= 0x10) && (i <= 0x17)) continue; /* no sprites here */ + int which2; + UINT8 sx1, sy1; + + if ((which1 >= 0x10) && (which1 <= 0x17)) continue; /* no sprites here */ - if (get_sprite_xy(i, &sx1, &sy1)) + if (!get_sprite_xy(which1, &sx1, &sy1)) continue; + + for (which2 = which1 + 1; which2 < 0x20; which2++) { - for (j = i+1; j < 0x20; j++) + UINT8 sx2, sy2; + + if ((which2 >= 0x10) && (which2 <= 0x17)) continue; /* no sprites here */ + + if (!get_sprite_xy(which2, &sx2, &sy2)) continue; + + /* quickly rule out any pairs that cannot be touching */ + if ((abs((INT8)sx1 - (INT8)sx2) < 16) && + (abs((INT8)sy1 - (INT8)sy2) < 16)) { - if ((j >= 0x10) && (j <= 0x17)) continue; /* no sprites here */ + int reg; + + if (!check_sprite_sprite_bitpattern(machine, sx1, sy1, which1, sx2, sy2, which2)) continue; - if (get_sprite_xy(j, &sx2, &sy2)) + /* mark sprite as collided */ + /* note that only the sprite with the higher number is marked */ + /* as collided. This is how the hardware works and required */ + /* by Pirate Pete to be able to finish the last round. */ + + /* the last sprite has to be moved at the start of the list */ + if (which2 == 0x1f) { - /* rule out any pairs that cannot be touching */ - if ((abs((INT8)sx1 - (INT8)sx2) < 16) && - (abs((INT8)sy1 - (INT8)sy2) < 16)) - { - if (check_sprite_sprite_bitpattern(machine, sx1, sy1, i, sx2, sy2, j)) - { - /* mark sprite as collided */ - /* note that only the sprite with the higher number is marked */ - /* as collided. This is how the hardware works and required */ - /* by Pirate Pete to be able to finish the last round. */ - int reg; - - /* Here I am mimicking what I do in the sprite drawing code. */ - /* The last sprite has to be moved at the start of the list. */ - if (j == 0x1f) - { - reg = i >> 3; - if (reg == 3) reg = 2; - - taitosj_collision_reg[reg] |= (1 << (i & 0x07)); - } - else - { - reg = j >> 3; - if (reg == 3) reg = 2; - - taitosj_collision_reg[reg] |= (1 << (j & 0x07)); - } - } - } + reg = which1 >> 3; + if (reg == 3) reg = 2; + + taitosj_collision_reg[reg] |= (1 << (which1 & 0x07)); + } + else + { + reg = which2 >> 3; + if (reg == 3) reg = 2; + + taitosj_collision_reg[reg] |= (1 << (which2 & 0x07)); } } } @@ -508,27 +430,31 @@ static void check_sprite_sprite_collision(running_machine *machine) } -static void calculate_sprite_areas(running_machine *machine) +static void calculate_sprite_areas(running_machine *machine, int *sprites_on, rectangle *sprite_areas) { - UINT8 sx,sy; - int i,minx,miny,maxx,maxy; + int which; - for (i = 0x00; i < 0x20; i++) + for (which = 0; which < 0x20; which++) { - if ((i >= 0x10) && (i <= 0x17)) continue; /* no sprites here */ + UINT8 sx, sy; - if (get_sprite_xy(i, &sx, &sy)) + if ((which >= 0x10) && (which <= 0x17)) continue; /* no sprites here */ + + if (get_sprite_xy(which, &sx, &sy)) { - if (flipscreen[0]) + int minx, miny, maxx, maxy; + + if (GLOBAL_FLIP_X) sx = 238 - sx; - if (flipscreen[1]) + + if (GLOBAL_FLIP_Y) sy = 242 - sy; minx = sx; miny = sy; - maxx = minx+15; - maxy = miny+15; + maxx = minx + 15; + maxy = miny + 15; /* check for bitmap bounds to avoid illegal memory access */ if (minx < 0) minx = 0; @@ -538,108 +464,166 @@ static void calculate_sprite_areas(running_machine *machine) if (maxy >= machine->screen[0].height - 1) maxy = machine->screen[0].height - 1; - spritearea[i].min_x = minx; - spritearea[i].max_x = maxx; - spritearea[i].min_y = miny; - spritearea[i].max_y = maxy; - spriteon[i] = 1; - } - else /* sprite is off */ - { - spriteon[i] = 0; + sprite_areas[which].min_x = minx; + sprite_areas[which].max_x = maxx; + sprite_areas[which].min_y = miny; + sprite_areas[which].max_y = maxy; + + sprites_on[which] = 1; } + /* sprite is off */ + else + sprites_on[which] = 0; } } -static int check_sprite_plane_bitpattern(running_machine *machine, int num) + +static int check_sprite_layer_bitpattern(running_machine *machine, int which, rectangle *sprite_areas) { - int x,y,flipx,flipy,minx,miny,maxx,maxy; - int offs = num * 4; + int y; + offs_t offs = which * 4; int result = 0; /* no collisions */ - int check_playfield1 = taitosj_video_enable & playfield_enable_mask[0]; - int check_playfield2 = taitosj_video_enable & playfield_enable_mask[1]; - int check_playfield3 = taitosj_video_enable & playfield_enable_mask[2]; - - minx = spritearea[num].min_x; - miny = spritearea[num].min_y; - maxx = spritearea[num].max_x + 1; - maxy = spritearea[num].max_y + 1; + int check_layer_1 = *taitosj_video_mode & layer_enable_mask[0]; + int check_layer_2 = *taitosj_video_mode & layer_enable_mask[1]; + int check_layer_3 = *taitosj_video_mode & layer_enable_mask[2]; + int minx = sprite_areas[which].min_x; + int miny = sprite_areas[which].min_y; + int maxx = sprite_areas[which].max_x + 1; + int maxy = sprite_areas[which].max_y + 1; - flipx = taitosj_spritebank[offs + 2] & 1; - flipy = taitosj_spritebank[offs + 2] & 2; + int flip_x = (taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01) ^ GLOBAL_FLIP_X; + int flip_y = (taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02) ^ GLOBAL_FLIP_Y; - if (flipscreen[0]) - flipx = !flipx; - if (flipscreen[1]) - flipy = !flipy; - - /* draw sprite into a bitmap and check if playfields collide */ - drawgfx(sprite_plane_collbitmap1, machine->gfx[(taitosj_spritebank[offs + 3] & 0x40) ? 3 : 1], - taitosj_spritebank[offs + 3] & 0x3f, + /* draw sprite into a bitmap and check if layers collide */ + drawgfx(sprite_layer_collbitmap1, get_sprite_gfx_element(machine, which), + taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f, 0, - flipx, flipy, + flip_x, flip_y, 0,0, 0,TRANSPARENCY_NONE,0); - for (y = miny;y < maxy;y++) + for (y = miny; y < maxy; y++) { - for (x = minx;x < maxx;x++) + int x; + + for (x = minx; x < maxx; x++) { - if (*BITMAP_ADDR16(sprite_plane_collbitmap1, y-miny, x-minx) != machine->pens[0]) /* is there anything to check for ? */ + if (*BITMAP_ADDR16(sprite_layer_collbitmap1, y - miny, x - minx) != machine->pens[0]) /* is there anything to check for ? */ { - if (check_playfield1 && (*BITMAP_ADDR16(sprite_plane_collbitmap2[0], y, x) != machine->pens[0])) - { - result |= 1; /* collided */ - if (result == 7) goto done; - check_playfield1 = 0; - } - if (check_playfield2 && (*BITMAP_ADDR16(sprite_plane_collbitmap2[1], y, x) != machine->pens[0])) - { - result |= 2; /* collided */ - if (result == 7) goto done; - check_playfield2 = 0; + if (check_layer_1 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[0], y, x) != machine->pens[0])) + result |= 0x01; /* collided with layer 1 */ - } - if (check_playfield3 && (*BITMAP_ADDR16(sprite_plane_collbitmap2[2], y, x) != machine->pens[0])) - { - result |= 4; /* collided */ - if (result == 7) goto done; - check_playfield3 = 0; - } + if (check_layer_2 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[1], y, x) != machine->pens[0])) + result |= 0x02; /* collided with layer 2 */ + + if (check_layer_3 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[2], y, x) != machine->pens[0])) + result |= 0x04; /* collided with layer 3 */ } } } -done: return result; } -static void check_sprite_plane_collision(running_machine *machine) + +static void check_sprite_layer_collision(running_machine *machine, int *sprites_on, rectangle *sprite_areas) { - UINT8 i; + if (SPRITES_ON) + { + int which; + + /* check each sprite */ + for (which = 0; which < 0x20; which++) + { + if ((which >= 0x10) && (which <= 0x17)) continue; /* no sprites here */ + + if (sprites_on[which]) + taitosj_collision_reg[3] |= check_sprite_layer_bitpattern(machine, which, sprite_areas); + } + } +} - if (taitosj_video_enable & 0x80) // check OBJOFF +static void decode_modified(running_machine *machine) +{ + offs_t offs; + + /* decode modified characters */ + for (offs = 0;offs < 256;offs++) { - /* check each sprite */ - for (i = 0x00; i < 0x20; i++) + if (dirtycharacter1[offs] == 1) { - if ((i >= 0x10) && (i <= 0x17)) continue; /* no sprites here */ + decodechar(machine->gfx[0], offs, taitosj_characterram); + dirtycharacter1[offs] = 0; + } - if (spriteon[i]) - { - taitosj_collision_reg[3] |= check_sprite_plane_bitpattern(machine, i); - } + if (dirtycharacter2[offs] == 1) + { + decodechar(machine->gfx[2], offs, taitosj_characterram + 0x1800); + dirtycharacter2[offs] = 0; + } + } + + /* decode modified sprites */ + for (offs = 0;offs < 64;offs++) + { + if (dirtysprite1[offs] == 1) + { + decodechar(machine->gfx[1], offs, taitosj_characterram); + dirtysprite1[offs] = 0; + } + + if (dirtysprite2[offs] == 1) + { + decodechar(machine->gfx[3], offs, taitosj_characterram + 0x1800); + dirtysprite2[offs] = 0; } } } +static void draw_layers(running_machine *machine) +{ + offs_t offs; + + for (offs = 0; offs < 0x0400; offs++) + { + int sx = offs % 32; + int sy = offs / 32; + + if (GLOBAL_FLIP_X) sx = 31 - sx; + if (GLOBAL_FLIP_Y) sy = 31 - sy; + + 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 */ + GLOBAL_FLIP_X,GLOBAL_FLIP_Y, + 8*sx,8*sy, + 0,TRANSPARENCY_NONE,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 */ + GLOBAL_FLIP_X,GLOBAL_FLIP_Y, + 8*sx,8*sy, + 0,TRANSPARENCY_NONE,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 */ + GLOBAL_FLIP_X,GLOBAL_FLIP_Y, + 8*sx,8*sy, + 0,TRANSPARENCY_NONE,0); + } +} + + static void draw_sprites(running_machine *machine, mame_bitmap *bitmap) { - /* sprite visibility area is missing 4 pixels from the sides, surely to reduce + /* + sprite visibility area is missing 4 pixels from the sides, surely to reduce wraparound side effects. This was verified on a real Elevator Action. Note that the clipping is asymmetrical. This matches the real thing. I'm not sure of what should happen when the screen is flipped, though. @@ -655,280 +639,206 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap) 2*8, 30*8-1 }; - if (taitosj_video_enable & 0x80) // check OBJOFF + if (SPRITES_ON) { int sprite; - /* drawing order is a bit strange. The last sprite has to be moved at the start of the list. */ - for (sprite = 0x1f;sprite >= 0;sprite--) + for (sprite = 0x1f; sprite >= 0; sprite--) { - UINT8 sx,sy,flipx,flipy; - int offs = ((sprite - 1) & 0x1f) * 4; // move last sprite at the head of the list - + UINT8 sx, sy; - if ((offs >= 0x40) && (offs <= 0x5f)) continue; /* no sprites here */ + int which = (sprite - 1) & 0x1f; /* move last sprite at the head of the list */ + offs_t offs = which * 4; + if ((which >= 0x10) && (which <= 0x17)) continue; /* no sprites here */ - if (get_sprite_xy(offs / 4, &sx, &sy)) + if (get_sprite_xy(which, &sx, &sy)) { - flipx = taitosj_spritebank[offs + 2] & 1; - flipy = taitosj_spritebank[offs + 2] & 2; - if (flipscreen[0]) + int code = taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f; + int color = 2 * ((taitosj_colorbank[1] >> 4) & 0x03) + ((taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] >> 2) & 0x01); + int flip_x = taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01; + int flip_y = taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02; + + if (GLOBAL_FLIP_X) { sx = 238 - sx; - flipx = !flipx; + flip_x = !flip_x; } - if (flipscreen[1]) + + if (GLOBAL_FLIP_Y) { sy = 242 - sy; - flipy = !flipy; + flip_y = !flip_y; } - drawgfx(bitmap,machine->gfx[(taitosj_spritebank[offs + 3] & 0x40) ? 3 : 1], - taitosj_spritebank[offs + 3] & 0x3f, - 2 * ((taitosj_colorbank[1] >> 4) & 0x03) + ((taitosj_spritebank[offs + 2] >> 2) & 1), - flipx,flipy, - sx,sy, - flipscreen[0] ? &spritevisibleareaflip : &spritevisiblearea,TRANSPARENCY_PEN,0); + drawgfx(bitmap, get_sprite_gfx_element(machine, which), code, color, + flip_x, flip_y, sx, sy, + GLOBAL_FLIP_X ? &spritevisibleareaflip : &spritevisiblearea,TRANSPARENCY_PEN,0); /* draw with wrap around. The horizontal games (eg. sfposeid) need this */ - drawgfx(bitmap,machine->gfx[(taitosj_spritebank[offs + 3] & 0x40) ? 3 : 1], - taitosj_spritebank[offs + 3] & 0x3f, - 2 * ((taitosj_colorbank[1] >> 4) & 0x03) + ((taitosj_spritebank[offs + 2] >> 2) & 1), - flipx,flipy, - sx - 0x100,sy, - flipscreen[0] ? &spritevisibleareaflip : &spritevisiblearea,TRANSPARENCY_PEN,0); + drawgfx(bitmap, get_sprite_gfx_element(machine, which), code, color, + flip_x, flip_y, sx - 0x100, sy, + GLOBAL_FLIP_X ? &spritevisibleareaflip : &spritevisiblearea,TRANSPARENCY_PEN,0); } } } } -static void draw_playfield(running_machine *machine, int n, mame_bitmap *bitmap) +static void taitosj_copy_layer(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, + int which, int *sprites_on, rectangle *sprite_areas) { static const int fudge1[3] = { 3, 1, -1 }; static const int fudge2[3] = { 8, 10, 12 }; - if (taitosj_video_enable & playfield_enable_mask[n]) + if (*taitosj_video_mode & layer_enable_mask[which]) { - int i,scrollx,scrolly[32]; + int i, scrollx, scrolly[32]; + scrollx = taitosj_scroll[2 * which]; - scrollx = taitosj_scroll[2*n]; - if (flipscreen[0]) - scrollx = (scrollx & 0xf8) + ((scrollx + fudge1[n]) & 7) + fudge2[n]; + if (GLOBAL_FLIP_X) + scrollx = (scrollx & 0xf8) + ((scrollx + fudge1[which]) & 7) + fudge2[which]; else - scrollx = -(scrollx & 0xf8) + ((scrollx + fudge1[n]) & 7) + fudge2[n]; + scrollx = -(scrollx & 0xf8) + ((scrollx + fudge1[which]) & 7) + fudge2[which]; - if (flipscreen[1]) + if (GLOBAL_FLIP_Y) { for (i = 0;i < 32;i++) - scrolly[31-i] = taitosj_colscrolly[32*n+i] + taitosj_scroll[2*n+1]; + 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*n+i] - taitosj_scroll[2*n+1]; + scrolly[i] = -taitosj_colscrolly[32 * which + i] - taitosj_scroll[2 * which + 1]; } - copyscrollbitmap(bitmap,taitosj_tmpbitmap[n],1,&scrollx,32,scrolly,&machine->screen[0].visarea,TRANSPARENCY_COLOR,0); + copyscrollbitmap(bitmap, taitosj_layer_bitmap[which], 1, &scrollx, 32, scrolly, cliprect, TRANSPARENCY_COLOR,0); - /* store parts covered with sprites for sprites/playfields collision detection */ - for (i=0x00; i<0x20; i++) + /* store parts covered with sprites for sprites/layers collision detection */ + for (i = 0; i < 0x20; i++) { if ((i >= 0x10) && (i <= 0x17)) continue; /* no sprites here */ - if (spriteon[i]) - copyscrollbitmap( sprite_plane_collbitmap2[n],taitosj_tmpbitmap[n],1,&scrollx,32,scrolly,&spritearea[i],TRANSPARENCY_NONE,0); + + if (sprites_on[i]) + copyscrollbitmap(sprite_layer_collbitmap2[which], taitosj_layer_bitmap[which], 1, &scrollx, 32, scrolly, &sprite_areas[i], TRANSPARENCY_NONE,0); } } } -static void kikstart_draw_playfield(running_machine *machine, int n, mame_bitmap *bitmap) + +static void kikstart_copy_layer(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, + int which, int *sprites_on, rectangle *sprite_areas) { - if (taitosj_video_enable & playfield_enable_mask[n]) + if (*taitosj_video_mode & layer_enable_mask[which]) { - int i,scrolly,scrollx[32*8]; + int i, scrolly, scrollx[32 * 8]; - for (i = 1;i < 32*8;i++)// 1-255 ! + for (i = 1; i < 32*8; i++) /* 1-255 ! */ { - if(flipscreen[1]) + if (GLOBAL_FLIP_Y) { - switch(n) + switch (which) { - case 0: scrollx[32*8-i] = 0 ;break; - case 1: scrollx[32*8-i] = kikstart_scrollram[i]+((taitosj_scroll[2*n]+0xa)&0xff);break; - case 2: scrollx[32*8-i] = kikstart_scrollram[0x100+i]+((taitosj_scroll[2*n]+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(n) + switch (which) { case 0: scrollx[i] = 0 ;break; - case 1: scrollx[i] = 0xff-kikstart_scrollram[i-1]-((taitosj_scroll[2*n]-0x10)&0xff);break; - case 2: scrollx[i] = 0xff-kikstart_scrollram[0x100+i-1]-((taitosj_scroll[2*n]-0x12)&0xff);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*n+1];//always 0 ? - copyscrollbitmap(bitmap,taitosj_tmpbitmap[n],32*8,scrollx,1,&scrolly,&machine->screen[0].visarea,TRANSPARENCY_COLOR,0); - /* store parts covered with sprites for sprites/playfields collision detection */ - for (i=0x00; i<0x20; i++) + + scrolly = taitosj_scroll[2 * which + 1]; /* always 0 */ + copyscrollbitmap(bitmap, taitosj_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, cliprect, TRANSPARENCY_COLOR, 0); + + /* store parts covered with sprites for sprites/layers collision detection */ + for (i = 0; i < 0x20; i++) { if ((i >= 0x10) && (i <= 0x17)) continue; /* no sprites here */ - if (spriteon[i]) - copyscrollbitmap( sprite_plane_collbitmap2[n],taitosj_tmpbitmap[n],32*8,scrollx,1,&scrolly,&spritearea[i],TRANSPARENCY_NONE,0); + + if (sprites_on[i]) + copyscrollbitmap(sprite_layer_collbitmap2[which], taitosj_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, &sprite_areas[i], TRANSPARENCY_NONE,0); } } } -static void draw_plane(running_machine *machine, int n, mame_bitmap *bitmap) +static void copy_layer(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, + copy_layer_func_t copy_layer_func, int which, int *sprites_on, rectangle *sprite_areas) { - switch (n) - { - case 0: + if (which == 0) draw_sprites(machine, bitmap); - break; - case 1: - case 2: - case 3: - if(!strcmp(machine->gamedrv->name,"kikstart")) - kikstart_draw_playfield(machine, n - 1, bitmap); - else - draw_playfield(machine, n - 1, bitmap); - break; - } + else + copy_layer_func(machine, bitmap, cliprect, which - 1, sprites_on, sprite_areas); } -VIDEO_UPDATE( taitosj ) +static void copy_layers(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, + copy_layer_func_t copy_layer_func, int *sprites_on, rectangle *sprite_areas) { - int offs,i,alldirty = 0; + int i = 0; + /* fill the screen with the background color */ + fillbitmap(bitmap, machine->pens[8 * (taitosj_colorbank[1] & 0x07)], cliprect); - /* decode modified characters */ - for (offs = 0;offs < 256;offs++) + for (i = 0; i < 4; i++) { - if (dirtycharacter1[offs] == 1) - { - decodechar(machine->gfx[0],offs,taitosj_characterram); - dirtycharacter1[offs] = 0; - alldirty = 1; - } - if (dirtycharacter2[offs] == 1) - { - decodechar(machine->gfx[2],offs,taitosj_characterram + 0x1800); - dirtycharacter2[offs] = 0; - alldirty = 1; - } - } + int which = draworder[*taitosj_video_priority & 0x1f][i]; - /* if characters changed, redraw everything */ - if (alldirty) - { - memset(dirtybuffer, 1,videoram_size); - memset(dirtybuffer2,1,videoram_size); - memset(dirtybuffer3,1,videoram_size); + copy_layer(machine, bitmap, cliprect, copy_layer_func, which, sprites_on, sprite_areas); } +} - /* decode modified sprites */ - for (offs = 0;offs < 64;offs++) - { - if (dirtysprite1[offs] == 1) - { - decodechar(machine->gfx[1],offs,taitosj_characterram); - dirtysprite1[offs] = 0; - } - if (dirtysprite2[offs] == 1) - { - decodechar(machine->gfx[3],offs,taitosj_characterram + 0x1800); - dirtysprite2[offs] = 0; - } - } - - - /* for every character in the Video RAM, check if it has been modified */ - /* since last time and update it accordingly. */ - for (offs = videoram_size - 1;offs >= 0;offs--) - { - if (dirtybuffer[offs]) - { - int sx,sy; - - - dirtybuffer[offs] = 0; - - sx = offs % 32; - sy = offs / 32; - if (flipscreen[0]) sx = 31 - sx; - if (flipscreen[1]) sy = 31 - sy; - - drawgfx(taitosj_tmpbitmap[0],machine->gfx[taitosj_colorbank[0] & 0x08 ? 2 : 0], - videoram[offs], - (taitosj_colorbank[0] & 0x07) + 8, /* use transparent pen 0 */ - flipscreen[0],flipscreen[1], - 8*sx,8*sy, - 0,TRANSPARENCY_NONE,0); - } - - if (dirtybuffer2[offs]) - { - int sx,sy; +static void check_collision(running_machine *machine, int *sprites_on, rectangle *sprite_areas) +{ + check_sprite_sprite_collision(machine); - dirtybuffer2[offs] = 0; + check_sprite_layer_collision(machine, sprites_on, sprite_areas); - sx = offs % 32; - sy = offs / 32; - if (flipscreen[0]) sx = 31 - sx; - if (flipscreen[1]) sy = 31 - sy; + /*check_layer_layer_collision();*/ /* not implemented !!! */ +} - drawgfx(taitosj_tmpbitmap[1],machine->gfx[taitosj_colorbank[0] & 0x80 ? 2 : 0], - taitosj_videoram2[offs], - ((taitosj_colorbank[0] >> 4) & 0x07) + 8, /* use transparent pen 0 */ - flipscreen[0],flipscreen[1], - 8*sx,8*sy, - 0,TRANSPARENCY_NONE,0); - } - if (dirtybuffer3[offs]) - { - int sx,sy; +static int video_update_common(running_machine *machine, mame_bitmap *bitmap, + const rectangle *cliprect, copy_layer_func_t copy_layer_func) +{ + int sprites_on[0x20]; /* 1 if sprite is active */ + rectangle sprite_areas[0x20]; /* areas on bitmap (sprite locations) */ + set_colors(machine); - dirtybuffer3[offs] = 0; + decode_modified(machine); - sx = offs % 32; - sy = offs / 32; - if (flipscreen[0]) sx = 31 - sx; - if (flipscreen[1]) sy = 31 - sy; + draw_layers(machine); - drawgfx(taitosj_tmpbitmap[2],machine->gfx[taitosj_colorbank[1] & 0x08 ? 2 : 0], - taitosj_videoram3[offs], - (taitosj_colorbank[1] & 0x07) + 8, /* use transparent pen 0 */ - flipscreen[0],flipscreen[1], - 8*sx,8*sy, - 0,TRANSPARENCY_NONE,0); - } - } + calculate_sprite_areas(machine, sprites_on, sprite_areas); + copy_layers(machine, bitmap, cliprect, copy_layer_func, sprites_on, sprite_areas); - /*called here because draw_playfield() uses its output (spritearea[32]) */ - calculate_sprite_areas(machine); + /*check_sprite_layer_collision() uses drawn bitmaps, so it must me called _AFTER_ draw_layers() */ + check_collision(machine, sprites_on, sprite_areas); - /* first of all, fill the screen with the background color */ - fillbitmap(bitmap,machine->pens[8 * (taitosj_colorbank[1] & 0x07)], cliprect); + return 0; +} - for (i = 0;i < 4;i++) - draw_plane(machine, draworder[*taitosj_video_priority & 0x1f][i],bitmap); - check_sprite_sprite_collision(machine); +VIDEO_UPDATE( taitosj ) +{ + return video_update_common(machine, bitmap, cliprect, taitosj_copy_layer); +} - /*check_sprite_plane_collision() uses drawn bitmaps, so it must me called _AFTER_ drawplane() */ - check_sprite_plane_collision(machine); - /*check_plane_plane_collision();*/ /*not implemented !!!*/ - return 0; +VIDEO_UPDATE( kikstart ) +{ + return video_update_common(machine, bitmap, cliprect, kikstart_copy_layer); } |
