From da2695a5c8be640c2660458cb1ff1d11cb132cbe Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 9 Jul 2023 17:16:09 +0200 Subject: changela: screen raw params, fixed gas pedal sensitivity, small cleanups --- src/mame/layout/changela.lay | 8 +- src/mame/taito/changela.cpp | 371 +++++++++++++++++++++--------------------- src/mame/taito/changela.h | 107 +++++++----- src/mame/taito/changela_v.cpp | 148 ++++++++--------- 4 files changed, 324 insertions(+), 310 deletions(-) diff --git a/src/mame/layout/changela.lay b/src/mame/layout/changela.lay index eaee69054eb..3895ced9992 100644 --- a/src/mame/layout/changela.lay +++ b/src/mame/layout/changela.lay @@ -55,7 +55,7 @@ license:CC0-1.0 - + @@ -64,7 +64,7 @@ license:CC0-1.0 - + @@ -73,7 +73,7 @@ license:CC0-1.0 - + @@ -81,7 +81,7 @@ license:CC0-1.0 - + diff --git a/src/mame/taito/changela.cpp b/src/mame/taito/changela.cpp index 26c8ff7e250..d8091e211d9 100644 --- a/src/mame/taito/changela.cpp +++ b/src/mame/taito/changela.cpp @@ -23,23 +23,72 @@ Tomasz Slanina #include "changela.lh" -uint8_t changela_state::mcu_r() +void changela_state::machine_start() { - //osd_printf_debug("Z80 MCU R = %x\n", m_mcu_out); - return m_mcu_out; + // video + save_item(NAME(m_sloperom_bank)); + save_item(NAME(m_tree_en)); + save_item(NAME(m_horizon)); + save_item(NAME(m_mem_dev_selected)); + save_item(NAME(m_v_count_river)); + save_item(NAME(m_v_count_tree)); + save_item(NAME(m_tree_on)); + + // mcu + save_item(NAME(m_port_a_out)); + save_item(NAME(m_port_c_out)); + save_item(NAME(m_mcu_out)); + save_item(NAME(m_mcu_in)); + + // misc + save_item(NAME(m_tree0_col)); + save_item(NAME(m_tree1_col)); + save_item(NAME(m_left_bank_col)); + save_item(NAME(m_right_bank_col)); + save_item(NAME(m_boat_shore_col)); + save_item(NAME(m_collision_reset)); + save_item(NAME(m_tree_collision_reset)); + save_item(NAME(m_prev_value_31)); + save_item(NAME(m_dir_31)); } -/* latch LS374 at U39 */ -void changela_state::mcu_w(uint8_t data) +void changela_state::machine_reset() { - m_mcu_in = data; - if (!BIT(m_port_c_out, 2)) - m_mcu->pa_w(data); + // video + m_sloperom_bank = 0; + m_tree_en = 0; + m_horizon = 0; + m_mem_dev_selected = 0; + m_v_count_river = 0; + m_v_count_tree = 0; + m_tree_on[0] = 0; + m_tree_on[1] = 0; + + // misc + m_tree0_col = 0; + m_tree1_col = 0; + m_left_bank_col = 0; + m_right_bank_col = 0; + m_boat_shore_col = 0; + m_collision_reset = 0; + m_tree_collision_reset = 0; + m_prev_value_31 = 0; + m_dir_31 = 0; +} + +TIMER_DEVICE_CALLBACK_MEMBER(changela_state::changela_scanline) +{ + int scanline = param; + + if (scanline == 256) // vblank irq + m_maincpu->set_input_line_and_vector(0, HOLD_LINE,0xdf); // Z80 + else if (((scanline % 64) == 0)) // timer irq, 3 times per given vblank field + m_maincpu->set_input_line_and_vector(0, HOLD_LINE,0xcf); // Z80 } /********************************* - MCU + MCU *********************************/ void changela_state::changela_68705_port_a_w(uint8_t data) @@ -49,33 +98,61 @@ void changela_state::changela_68705_port_a_w(uint8_t data) void changela_state::changela_68705_port_c_w(uint8_t data) { - /* PC3 is connected to the CLOCK input of the LS374, so we latch the data on rising edge */ + // PC3 is connected to the CLOCK input of the LS374, so we latch the data on rising edge if (BIT(data, 3) && !BIT(m_port_c_out, 3)) - m_mcu_out = m_port_a_out & (BIT(m_port_c_out, 2) ? 0xff : m_mcu_in); + m_mcu_out = m_port_a_out; - /* PC2 is connected to the /OE input of the LS374 */ + // PC2 is connected to the /OE input of the LS374 m_mcu->pa_w(BIT(data, 2) ? 0xff : m_mcu_in); m_port_c_out = data; } +// latch LS374 at U40 +uint8_t changela_state::mcu_r() +{ + //osd_printf_debug("Z80 MCU R = %x\n", m_mcu_out); + return m_mcu_out & (BIT(m_port_c_out, 2) ? 0xff : m_mcu_in); +} +// latch LS374 at U39 +void changela_state::mcu_w(uint8_t data) +{ + m_mcu_in = data; + if (!BIT(m_port_c_out, 2)) + m_mcu->pa_w(data); +} -/* U30 */ +// U30 uint8_t changela_state::changela_24_r() { - return (BIT(m_port_c_out, 1) << 3) | 0x07; /* bits 2,1,0-N/C inputs */ + return (BIT(m_port_c_out, 1) << 3) | 0x07; // bits 2,1,0-N/C inputs } +void changela_state::mcu_pc_0_w(int state) +{ + m_mcu->pc_w(0xfe | state); +} + +INTERRUPT_GEN_MEMBER(changela_state::chl_mcu_irq) +{ + m_mcu->pulse_input_line(0, m_mcu->minimum_quantum_time()); +} + + +/********************************* + Other I/O +*********************************/ + uint8_t changela_state::changela_25_r() { - //collisions on bits 3,2, bits 1,0-N/C inputs + // collisions on bits 3,2, bits 1,0-N/C inputs return (m_tree1_col << 3) | (m_tree0_col << 2) | 0x03; } uint8_t changela_state::changela_30_r() { - return ioport("WHEEL")->read() & 0x0f; //wheel control (clocked input) signal on bits 3,2,1,0 + return m_wheel->read() & 0x0f; // wheel control (clocked input) signal on bits 3,2,1,0 } uint8_t changela_state::changela_31_r() @@ -83,10 +160,10 @@ uint8_t changela_state::changela_31_r() /* If the new value is less than the old value, and it did not wrap around, or if the new value is greater than the old value, and it did wrap around, then we are moving LEFT. */ - uint8_t curr_value = ioport("WHEEL")->read(); + uint8_t curr_value = m_wheel->read(); if ((curr_value < m_prev_value_31 && (m_prev_value_31 - curr_value) < 0x80) - || (curr_value > m_prev_value_31 && (curr_value - m_prev_value_31) > 0x80)) + || (curr_value > m_prev_value_31 && (curr_value - m_prev_value_31) > 0x80)) m_dir_31 = 1; if ((m_prev_value_31 < curr_value && (curr_value - m_prev_value_31) < 0x80) || (m_prev_value_31 > curr_value && (m_prev_value_31 - curr_value) > 0x80)) @@ -94,30 +171,16 @@ uint8_t changela_state::changela_31_r() m_prev_value_31 = curr_value; - //wheel UP/DOWN control signal on bit 3, collisions on bits:2,1,0 + // wheel UP/DOWN control signal on bit 3, collisions on bits:2,1,0 return (m_dir_31 << 3) | (m_left_bank_col << 2) | (m_right_bank_col << 1) | m_boat_shore_col; } -uint8_t changela_state::changela_2c_r() -{ - int val = ioport("IN0")->read(); - - val = (val & 0x30) | ((val & 1) << 7) | (((val & 1) ^ 1) << 6); - - return val; -} - uint8_t changela_state::changela_2d_r() { - /* the schems are unreadable - I'm not sure it is V8 (page 74, SOUND I/O BOARD SCHEMATIC 1 OF 2, FIGURE 24 - in the middle on the right side) */ - int v8 = 0; int gas; - if ((m_screen->vpos() & 0xf8) == 0xf8) - v8 = 1; - - /* Gas pedal is made up of 2 switches, 1 active low, 1 active high */ - switch (ioport("IN1")->read() & 0x03) + // Gas pedal is made up of 2 switches, 1 active low, 1 active high + switch (m_gas->read() & 0x03) { case 0x02: gas = 0x80; @@ -130,12 +193,7 @@ uint8_t changela_state::changela_2d_r() break; } - return (ioport("IN1")->read() & 0x20) | gas | (v8 << 4); -} - -void changela_state::mcu_pc_0_w(int state) -{ - m_mcu->pc_w(0xfe | state); + return (m_inputs[1]->read() & 0x20) | gas | (m_screen->vpos() >> 4 & 0x10); } void changela_state::collision_reset_0_w(int state) @@ -159,55 +217,63 @@ void changela_state::coin_counter_2_w(int state) } +/********************************* + Address Map +*********************************/ + void changela_state::changela_map(address_map &map) { map(0x0000, 0x7fff).rom(); - map(0x8000, 0x83ff).ram().share("spriteram"); /* OBJ0 RAM */ - map(0x9000, 0x97ff).ram().share("videoram"); /* OBJ1 RAM */ - map(0xa000, 0xa07f).w(FUNC(changela_state::changela_colors_w)).share("colorram"); /* Color 93419 RAM 64x9(nine!!!) bits A0-used as the 8-th bit data input (d0-d7->normal, a0->d8) */ + map(0x8000, 0x83ff).ram().share("spriteram"); // OBJ0 RAM + map(0x9000, 0x97ff).ram().share("videoram"); // OBJ1 RAM + map(0xa000, 0xa07f).w(FUNC(changela_state::changela_colors_w)).share("colorram"); // Color 93419 RAM 64x9(nine!!!) bits A0-used as the 8-th bit data input (d0-d7->normal, a0->d8) map(0xb000, 0xbfff).rom(); - map(0xc000, 0xc7ff).rw(FUNC(changela_state::changela_mem_device_r), FUNC(changela_state::changela_mem_device_w)); /* RAM4 (River Bed RAM); RAM5 (Tree RAM) */ + map(0xc000, 0xc7ff).rw(FUNC(changela_state::changela_mem_device_r), FUNC(changela_state::changela_mem_device_w)); // RAM4 (River Bed RAM); RAM5 (Tree RAM) - /* LS138 - U16 */ - map(0xc800, 0xc800).nopw(); /* not connected */ - map(0xc900, 0xc900).w(FUNC(changela_state::changela_mem_device_select_w)); /* selects the memory device to be accessible at 0xc000-0xc7ff */ + // LS138 - U16 + map(0xc800, 0xc800).nopw(); // not connected + map(0xc900, 0xc900).w(FUNC(changela_state::changela_mem_device_select_w)); // selects the memory device to be accessible at 0xc000-0xc7ff map(0xca00, 0xca00).w(FUNC(changela_state::changela_slope_rom_addr_hi_w)); map(0xcb00, 0xcb00).w(FUNC(changela_state::changela_slope_rom_addr_lo_w)); map(0xd000, 0xd001).rw("ay1", FUNC(ay8910_device::data_r), FUNC(ay8910_device::address_data_w)); map(0xd010, 0xd011).rw("ay2", FUNC(ay8910_device::data_r), FUNC(ay8910_device::address_data_w)); - /* LS259 - U44 */ + // LS259 - U44 map(0xd020, 0xd027).w("outlatch", FUNC(ls259_device::write_d0)); - /* LS139 - U24 */ + // LS139 - U24 map(0xd024, 0xd024).r(FUNC(changela_state::changela_24_r)); map(0xd025, 0xd025).r(FUNC(changela_state::changela_25_r)); map(0xd028, 0xd028).r(FUNC(changela_state::mcu_r)); - map(0xd02c, 0xd02c).r(FUNC(changela_state::changela_2c_r)); + map(0xd02c, 0xd02c).portr("IN0"); map(0xd02d, 0xd02d).r(FUNC(changela_state::changela_2d_r)); map(0xd030, 0xd030).rw(FUNC(changela_state::changela_30_r), FUNC(changela_state::mcu_w)); map(0xd031, 0xd031).r(FUNC(changela_state::changela_31_r)); - map(0xe000, 0xe000).w("watchdog", FUNC(watchdog_timer_device::reset_w)); /* Watchdog */ + map(0xe000, 0xe000).w("watchdog", FUNC(watchdog_timer_device::reset_w)); - map(0xf000, 0xf7ff).ram(); /* RAM2 (Processor RAM) */ + map(0xf000, 0xf7ff).ram(); // RAM2 (Processor RAM) } +/********************************* + Input Ports +*********************************/ + static INPUT_PORTS_START( changela ) - PORT_START("DSWA") /* DSWA */ + PORT_START("DSWA") // DSWA PORT_DIPNAME( 0x07, 0x01, "Steering Wheel Ratio" ) PORT_DIPLOCATION("SWA:1,2,3") - //PORT_DIPSETTING( 0x00, "?" ) /* Not documented */ - PORT_DIPSETTING( 0x01, "Recommended Setting" ) - //PORT_DIPSETTING( 0x02, "?" ) /* Not documented */ - //PORT_DIPSETTING( 0x03, "?" ) /* Not documented */ - //PORT_DIPSETTING( 0x04, "?" ) /* Not documented */ - //PORT_DIPSETTING( 0x05, "?" ) /* Not documented */ - //PORT_DIPSETTING( 0x06, "?" ) /* Not documented */ - //PORT_DIPSETTING( 0x07, "?" ) /* Not documented */ + PORT_DIPSETTING( 0x00, "0" ) + PORT_DIPSETTING( 0x01, "1" ) + PORT_DIPSETTING( 0x02, "2" ) + PORT_DIPSETTING( 0x03, "3" ) + PORT_DIPSETTING( 0x04, "4" ) + PORT_DIPSETTING( 0x05, "5" ) + PORT_DIPSETTING( 0x06, "6" ) + PORT_DIPSETTING( 0x07, "7" ) PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SWA:4") PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -224,7 +290,7 @@ static INPUT_PORTS_START( changela ) PORT_DIPSETTING( 0x80, "1" ) PORT_DIPSETTING( 0x00, "2" ) - PORT_START("DSWB") /* DSWB */ + PORT_START("DSWB") // DSWB PORT_DIPNAME( 0x03, 0x00, "Max Bonus Fuels" ) PORT_DIPLOCATION("SWB:1,2") PORT_DIPSETTING( 0x01, "1" ) PORT_DIPSETTING( 0x02, "2" ) @@ -240,14 +306,14 @@ static INPUT_PORTS_START( changela ) PORT_DIPSETTING( 0x10, DEF_STR( Easy ) ) PORT_DIPSETTING( 0x20, DEF_STR( Medium ) ) PORT_DIPSETTING( 0x30, DEF_STR( Hard ) ) - PORT_DIPNAME( 0x40, 0x00, "Land Collisions Enabled" ) PORT_DIPLOCATION("SWB:7") - PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPNAME( 0x40, 0x00, "Land Collisions" ) PORT_DIPLOCATION("SWB:7") + PORT_DIPSETTING( 0x01, "Off (Cheat)" ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_DIPNAME( 0x80, 0x00, "Car Collision Enabled" ) PORT_DIPLOCATION("SWB:8") - PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) + PORT_DIPNAME( 0x80, 0x00, "Car Collision" ) PORT_DIPLOCATION("SWB:8") + PORT_DIPSETTING( 0x01, "Off (Cheat)" ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START("DSWC") /* DSWC - coinage */ + PORT_START("DSWC") // DSWC - coinage PORT_DIPNAME( 0xf0, 0x10, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWC:5,6,7,8") PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPSETTING( 0x90, DEF_STR( 2C_1C ) ) @@ -281,7 +347,7 @@ static INPUT_PORTS_START( changela ) PORT_DIPSETTING( 0x06, DEF_STR( 1C_6C ) ) PORT_DIPSETTING( 0x07, DEF_STR( 1C_7C ) ) - PORT_START("DSWD") /* DSWD - bonus */ + PORT_START("DSWD") // DSWD - bonus PORT_DIPNAME( 0x01, 0x01, "Right Slot" ) PORT_DIPLOCATION("SWD:1") PORT_DIPSETTING( 0x01, "On Right (Bottom) Counter" ) PORT_DIPSETTING( 0x00, "On Left (Top) Counter" ) @@ -297,132 +363,57 @@ static INPUT_PORTS_START( changela ) PORT_DIPSETTING( 0x14, "5" ) PORT_DIPSETTING( 0x18, "6" ) PORT_DIPSETTING( 0x1c, "7" ) - PORT_DIPUNUSED_DIPLOC( 0x20, IP_ACTIVE_LOW, "SWD:6" ) /* Listed as "Unused" */ - PORT_DIPNAME( 0x40, 0x00, "'King Of The World' Name Length" )PORT_DIPLOCATION("SWD:7") + PORT_DIPUNUSED_DIPLOC( 0x20, IP_ACTIVE_LOW, "SWD:6" ) // Listed as "Unused" + PORT_DIPNAME( 0x40, 0x00, "'King Of The World' Name Length" ) PORT_DIPLOCATION("SWD:7") PORT_DIPSETTING( 0x40, "3 Letters" ) PORT_DIPSETTING( 0x00, "Long" ) PORT_DIPNAME( 0x80, 0x00, "'King Of The World' Name" ) PORT_DIPLOCATION("SWD:8") PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START("MCU") /* MCU */ - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_START("MCU") // MCU + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 ) -#ifdef THREE_STATE_SWITCH - PORT_DIPNAME( 0x30, 0x30, "Self Test Switch" ) PORT_DIPLOCATION("SWT:1,2") - //PORT_DIPSETTING( 0x00, "?" ) /* Not possible, 3-state switch */ - PORT_DIPSETTING( 0x20, "Free Game" ) /* "Puts a credit on the game without increasing the coin counter." */ - PORT_DIPSETTING( 0x10, DEF_STR( Test ) ) - PORT_DIPSETTING( 0x30, DEF_STR( Off ) ) -#else // schematics don't make it clear exactly how this switch is supposed to work - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("Free Game/Self-Test") - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) -#endif + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 ) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) // COIN3 on schematics, but game only has 2 coin slots PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) - PORT_START("IN0") /* 0xDx2C */ - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Gear Shift") PORT_TOGGLE /* Gear shift */ + PORT_START("IN0") // 0xDx2C + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("DSWA", 0x20, EQUALS, 0x00) // SPARE + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CONDITION("DSWA", 0x20, EQUALS, 0x00) // SPARE PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_CONDITION("DSWA", 0x20, EQUALS, 0x20) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_CONDITION("DSWA", 0x20, EQUALS, 0x20) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* FWD - negated bit 7 */ - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* REV - gear position */ + PORT_BIT( 0x40, 0x40, IPT_CUSTOM ) PORT_CONDITION("GEAR", 0x01, EQUALS, 0x00) // FWD + PORT_BIT( 0x80, 0x80, IPT_CUSTOM ) PORT_CONDITION("GEAR", 0x01, EQUALS, 0x01) // REV - PORT_START("IN1") /* 0xDx2D */ - PORT_BIT( 0x03, 0x00, IPT_PEDAL ) PORT_MINMAX(0x00, 0x02) PORT_SENSITIVITY(10) PORT_KEYDELTA(1) //gas pedal - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT ) - //PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) //gas1 - //PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) //gas2 + PORT_START("IN1") // 0xDx2D + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT ) - PORT_START("WHEEL") /* 0xDx30 DRIVING_WHEEL */ + PORT_START("WHEEL") // 0xDx30 PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_MINMAX(0x00, 0xff) PORT_SENSITIVITY(50) PORT_KEYDELTA(8) PORT_CONDITION("DSWA", 0x20, EQUALS, 0x00) -INPUT_PORTS_END - -TIMER_DEVICE_CALLBACK_MEMBER(changela_state::changela_scanline) -{ - int scanline = param; - - if(scanline == 256) // vblank irq - m_maincpu->set_input_line_and_vector(0, HOLD_LINE,0xdf); // Z80 - else if(((scanline % 64) == 0)) // timer irq, 3 times per given vblank field - m_maincpu->set_input_line_and_vector(0, HOLD_LINE,0xcf); // Z80 -} - -INTERRUPT_GEN_MEMBER(changela_state::chl_mcu_irq) -{ - m_mcu->pulse_input_line(0, m_mcu->minimum_quantum_time()); -} - -void changela_state::machine_start() -{ - /* video */ - save_item(NAME(m_slopeROM_bank)); - save_item(NAME(m_tree_en)); - save_item(NAME(m_horizon)); - save_item(NAME(m_mem_dev_selected)); - save_item(NAME(m_v_count_river)); - save_item(NAME(m_v_count_tree)); - save_item(NAME(m_tree_on)); - - /* mcu */ - save_item(NAME(m_port_a_out)); - save_item(NAME(m_port_c_out)); - save_item(NAME(m_mcu_out)); - save_item(NAME(m_mcu_in)); - - /* misc */ - save_item(NAME(m_tree0_col)); - save_item(NAME(m_tree1_col)); - save_item(NAME(m_left_bank_col)); - save_item(NAME(m_right_bank_col)); - save_item(NAME(m_boat_shore_col)); - save_item(NAME(m_collision_reset)); - save_item(NAME(m_tree_collision_reset)); - save_item(NAME(m_prev_value_31)); - save_item(NAME(m_dir_31)); - m_port_a_out = 0xff; - m_port_c_out = 0xff; -} + PORT_START("GAS") + PORT_BIT( 0x03, 0x00, IPT_PEDAL ) PORT_MINMAX(0x00, 0x02) PORT_SENSITIVITY(10) PORT_KEYDELTA(1) PORT_CONDITION("DSWA", 0x20, EQUALS, 0x00) -void changela_state::machine_reset() -{ - /* video */ - m_slopeROM_bank = 0; - m_tree_en = 0; - m_horizon = 0; - m_mem_dev_selected = 0; - m_v_count_river = 0; - m_v_count_tree = 0; - m_tree_on[0] = 0; - m_tree_on[1] = 0; + PORT_START("GEAR") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Gear Shift") PORT_TOGGLE +INPUT_PORTS_END - /* mcu */ - m_mcu_out = 0; - m_mcu_in = 0; - /* misc */ - m_tree0_col = 0; - m_tree1_col = 0; - m_left_bank_col = 0; - m_right_bank_col = 0; - m_boat_shore_col = 0; - m_collision_reset = 0; - m_tree_collision_reset = 0; - m_prev_value_31 = 0; - m_dir_31 = 0; -} +/********************************* + Machine Config +*********************************/ void changela_state::changela(machine_config &config) { - Z80(config, m_maincpu, 5000000); + Z80(config, m_maincpu, 20_MHz_XTAL/4); m_maincpu->set_addrmap(AS_PROGRAM, &changela_state::changela_map); TIMER(config, "scantimer").configure_scanline(FUNC(changela_state::changela_scanline), "screen", 0, 1); - M68705P3(config, m_mcu, 2500000); + M68705P3(config, m_mcu, 20_MHz_XTAL/8); m_mcu->portb_r().set_ioport("MCU"); m_mcu->porta_w().set(FUNC(changela_state::changela_68705_port_a_w)); m_mcu->portc_w().set(FUNC(changela_state::changela_68705_port_c_w)); @@ -438,9 +429,7 @@ void changela_state::changela(machine_config &config) WATCHDOG_TIMER(config, "watchdog"); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); - m_screen->set_refresh_hz(60); - m_screen->set_size(32*8, 262); /* vert size is a guess */ - m_screen->set_visarea(0*8, 32*8-1, 4*8, 32*8-1); + m_screen->set_raw(20_MHz_XTAL/4, 320, 8, 256, 262, 32, 256); m_screen->set_screen_update(FUNC(changela_state::screen_update_changela)); m_screen->set_palette(m_palette); @@ -448,51 +437,61 @@ void changela_state::changela(machine_config &config) SPEAKER(config, "mono").front_center(); - ay8910_device &ay1(AY8910(config, "ay1", 1250000)); + ay8910_device &ay1(AY8910(config, "ay1", 20_MHz_XTAL/16)); ay1.port_a_read_callback().set_ioport("DSWA"); ay1.port_b_read_callback().set_ioport("DSWB"); ay1.add_route(ALL_OUTPUTS, "mono", 0.50); - ay8910_device &ay2(AY8910(config, "ay2", 1250000)); + ay8910_device &ay2(AY8910(config, "ay2", 20_MHz_XTAL/16)); ay2.port_a_read_callback().set_ioport("DSWC"); ay2.port_b_read_callback().set_ioport("DSWD"); ay2.add_route(ALL_OUTPUTS, "mono", 0.50); } +/********************************* + Rom Definitions +*********************************/ + ROM_START( changela ) - ROM_REGION( 0x10000, "maincpu", 0 ) /* Z80 code */ + ROM_REGION( 0x10000, "maincpu", 0 ) // Z80 code ROM_LOAD( "cl25a", 0x0000, 0x2000, CRC(38530a60) SHA1(0b0ef1abe11c5271fcd1671322b77165217553c3) ) ROM_LOAD( "cl24a", 0x2000, 0x2000, CRC(2fcf4a82) SHA1(c33355e2d4d3fab32c8d713a680ec0fceedab341) ) ROM_LOAD( "cl23", 0x4000, 0x2000, CRC(08385891) SHA1(d8d66664ec25db067d5a4a6c35ec0ac65b9e0c6a) ) ROM_LOAD( "cl22a", 0x6000, 0x2000, CRC(796e0abd) SHA1(64dd9fc1f9bc44519a253ef0c02e181dd13904bf) ) // confirmed dumped from a cl22a labeled ROM. Previously MAME had it as cl22. Wrongly labeled before or do they really have same contents? ROM_LOAD( "cl27", 0xb000, 0x1000, CRC(3668afb8) SHA1(bcfb788baf806edcb129ea9f9dcb1d4260684773) ) - ROM_REGION( 0x00800, "mcu", 0 ) /* 68705P3 */ + ROM_REGION( 0x00800, "mcu", 0 ) // 68705P3 ROM_LOAD( "cl38a", 0x0000, 0x800, CRC(b70156ce) SHA1(c5eab8bbd65c4f587426298da4e22f991ce01dde) ) - ROM_REGION( 0x4000, "gfx1", 0 ) /* tile data */ + ROM_REGION( 0x4000, "tiles", 0 ) // tile data ROM_LOAD( "cl111", 0x0000, 0x2000, CRC(41c0149d) SHA1(3ea53a3821b044b3d0451fec1b4ee2c28da393ca) ) ROM_LOAD( "cl113", 0x2000, 0x2000, CRC(ddf99926) SHA1(e816b88302c5639c7284f4845d450f232d63a10c) ) - ROM_REGION( 0x1000, "gfx2", 0 ) /* obj 1 data */ - ROM_LOAD( "cl46", 0x0000, 0x1000, CRC(9c0a7d28) SHA1(fac9180ea0d9aeea56a84b35cc0958f0dd86a801) ) - - ROM_REGION( 0x8000, "user1", 0 ) /* obj 0 data */ + ROM_REGION( 0x8000, "obj0", 0 ) // obj 0 data ROM_LOAD( "cl100", 0x0000, 0x2000, CRC(3fa9e4fa) SHA1(9abd7df5fcf143a0c476bd8c8753c5ea294b9f74) ) ROM_LOAD( "cl99", 0x2000, 0x2000, CRC(67b27b9e) SHA1(7df0f93851959359218c8d2272e30d242a77039d) ) ROM_LOAD( "cl98", 0x4000, 0x2000, CRC(bffe4149) SHA1(5cf0b98f9d342bd06d575c565ea01bbd79f5e04b) ) ROM_LOAD( "cl97", 0x6000, 0x2000, CRC(5abab8f9) SHA1(f5156855bbcdf0740fd44520386318ee53ebbf9a) ) - ROM_REGION( 0x1000, "user2", 0 ) /* math tables: SLOPE ROM (river-tree schematic page 1/3) */ - ROM_LOAD( "cl44", 0x0000, 0x1000, CRC(160d2bc7) SHA1(2609208c2bd4618ea340923ee01af69278980c36) ) /* first and 2nd half identical */ + ROM_REGION( 0x1000, "obj1", 0 ) // obj 1 data + ROM_LOAD( "cl46", 0x0000, 0x1000, CRC(9c0a7d28) SHA1(fac9180ea0d9aeea56a84b35cc0958f0dd86a801) ) + + ROM_REGION( 0x1000, "slope", 0 ) // math tables: SLOPE ROM (river-tree schematic page 1/3) + ROM_LOAD( "cl44", 0x0000, 0x1000, CRC(160d2bc7) SHA1(2609208c2bd4618ea340923ee01af69278980c36) ) // first and 2nd half identical - ROM_REGION( 0x3000, "user3", 0 ) /* math tables: TREE ROM (river-tree schematic page 3/3)*/ - ROM_LOAD( "cl7", 0x0000, 0x0800, CRC(01e3efca) SHA1(b26203787f105ba32773e37035c39253050f9c82) ) /* fixed bits: 0xxxxxxx */ + ROM_REGION( 0x3000, "tree", 0 ) // math tables: TREE ROM (river-tree schematic page 3/3) + ROM_LOAD( "cl7", 0x0000, 0x0800, CRC(01e3efca) SHA1(b26203787f105ba32773e37035c39253050f9c82) ) // fixed bits: 0xxxxxxx ROM_LOAD( "cl9", 0x1000, 0x2000, CRC(4e53cdd0) SHA1(6255411cfdccbe2c581c83f9127d582623453c3a) ) ROM_REGION( 0x0020, "proms", 0 ) - ROM_LOAD( "cl88", 0x0000, 0x0020, CRC(da4d6625) SHA1(2d9a268973518252eb36f479ab650af8c16c885c) ) /* math train state machine */ + ROM_LOAD( "cl88", 0x0000, 0x0020, CRC(da4d6625) SHA1(2d9a268973518252eb36f479ab650af8c16c885c) ) // math train state machine ROM_END -GAMEL( 1983, changela, 0, changela, changela, changela_state, empty_init, ROT180, "Taito Corporation", "Change Lanes", MACHINE_SUPPORTS_SAVE, layout_changela ) + +/********************************* + Game Driver +*********************************/ + +// YEAR NAME PARENT MACHINE INPUT CLASS INIT SCREEN COMPANY FULLNAME FLAGS +GAMEL( 1983, changela, 0, changela, changela, changela_state, empty_init, ROT180, "Taito Corporation", "Change Lanes", MACHINE_SUPPORTS_SAVE, layout_changela ) diff --git a/src/mame/taito/changela.h b/src/mame/taito/changela.h index a82aac428ef..696e6d7f566 100644 --- a/src/mame/taito/changela.h +++ b/src/mame/taito/changela.h @@ -12,29 +12,66 @@ class changela_state : public driver_device public: changela_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) - , m_spriteram(*this, "spriteram") - , m_videoram(*this, "videoram") - , m_colorram(*this, "colorram") - , m_mcu(*this, "mcu") , m_maincpu(*this, "maincpu") + , m_mcu(*this, "mcu") , m_screen(*this, "screen") , m_palette(*this, "palette") - , m_port_a_out(0xff) - , m_port_c_out(0xff) - , m_mcu_out(0xff) - , m_mcu_in(0xff) + , m_spriteram(*this, "spriteram") + , m_videoram(*this, "videoram") + , m_colorram(*this, "colorram") + , m_tilerom(*this, "tiles") + , m_obj0rom(*this, "obj0") + , m_obj1rom(*this, "obj1") + , m_sloperom(*this, "slope") + , m_treerom(*this, "tree") + , m_proms(*this, "proms") + , m_inputs(*this, "IN%u", 0) + , m_gas(*this, "GAS") + , m_wheel(*this, "WHEEL") { } - /* video-related */ + void changela(machine_config &config); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + +private: + // devices/pointers + required_device m_maincpu; + required_device m_mcu; + required_device m_screen; + required_device m_palette; + + // memory pointers + required_shared_ptr m_spriteram; + required_shared_ptr m_videoram; + required_shared_ptr m_colorram; + required_region_ptr m_tilerom; + required_region_ptr m_obj0rom; + required_region_ptr m_obj1rom; + required_region_ptr m_sloperom; + required_region_ptr m_treerom; + required_region_ptr m_proms; + + // input ports + required_ioport_array<2> m_inputs; + required_ioport m_gas; + required_ioport m_wheel; + + void changela_map(address_map &map); + + // video-related bitmap_ind16 m_obj0_bitmap; bitmap_ind16 m_river_bitmap; bitmap_ind16 m_tree0_bitmap; bitmap_ind16 m_tree1_bitmap; - std::unique_ptr m_tree_ram; + std::unique_ptr m_treeram; std::unique_ptr m_memory_devices; - uint32_t m_mem_dev_selected = 0U; /* an offset within memory_devices area */ - uint32_t m_slopeROM_bank = 0U; + uint32_t m_mem_dev_selected = 0U; // an offset within memory_devices area + uint32_t m_sloperom_bank = 0U; uint8_t m_tree_en = 0U; uint8_t m_horizon = 0U; uint8_t m_v_count_river = 0U; @@ -42,7 +79,13 @@ public: int m_tree_on[2]{}; emu_timer* m_scanline_timer = nullptr; - /* misc */ + // mcu-related + uint8_t m_port_a_out = 0xff; + uint8_t m_port_c_out = 0xff; + uint8_t m_mcu_out = 0xff; + uint8_t m_mcu_in = 0xff; + + // misc uint8_t m_tree0_col = 0U; uint8_t m_tree1_col = 0U; uint8_t m_left_bank_col = 0U; @@ -53,7 +96,7 @@ public: uint8_t m_prev_value_31 = 0U; int m_dir_31 = 0; - /* devices */ + // devices uint8_t mcu_r(); void mcu_w(uint8_t data); void changela_68705_port_a_w(uint8_t data); @@ -62,7 +105,6 @@ public: uint8_t changela_25_r(); uint8_t changela_30_r(); uint8_t changela_31_r(); - uint8_t changela_2c_r(); uint8_t changela_2d_r(); void mcu_pc_0_w(int state); void collision_reset_0_w(int state); @@ -75,35 +117,14 @@ public: uint8_t changela_mem_device_r(offs_t offset); void changela_slope_rom_addr_hi_w(uint8_t data); void changela_slope_rom_addr_lo_w(uint8_t data); - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - uint32_t screen_update_changela(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(chl_mcu_irq); - TIMER_CALLBACK_MEMBER(changela_scanline_callback); TIMER_DEVICE_CALLBACK_MEMBER(changela_scanline); - void draw_obj0( bitmap_ind16 &bitmap, int sy ); - void draw_obj1( bitmap_ind16 &bitmap ); - void draw_river( bitmap_ind16 &bitmap, int sy ); - void draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ); - - void changela(machine_config &config); - void changela_map(address_map &map); -protected: - // memory pointers - required_shared_ptr m_spriteram; - required_shared_ptr m_videoram; - required_shared_ptr m_colorram; - - // devices - required_device m_mcu; - required_device m_maincpu; - required_device m_screen; - required_device m_palette; + TIMER_CALLBACK_MEMBER(changela_scanline_callback); - // mcu-related - u8 m_port_a_out; - u8 m_port_c_out; - u8 m_mcu_out; - u8 m_mcu_in; + uint32_t screen_update_changela(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void draw_obj0(bitmap_ind16 &bitmap, int sy); + void draw_obj1(bitmap_ind16 &bitmap); + void draw_river(bitmap_ind16 &bitmap, int sy); + void draw_tree(bitmap_ind16 &bitmap, int sy, int tree_num); }; diff --git a/src/mame/taito/changela_v.cpp b/src/mame/taito/changela_v.cpp index 47e8f5f524b..40cca32bd50 100644 --- a/src/mame/taito/changela_v.cpp +++ b/src/mame/taito/changela_v.cpp @@ -1,6 +1,7 @@ // license:GPL-2.0+ // copyright-holders:Jarek Burczynski, Phil Stroffolino, Tomasz Slanina /************************************************************************** + Change Lanes - Video Hardware (C) Taito 1983 @@ -9,7 +10,7 @@ Phil Stroffolino Tomasz Slanina Adam Bousley -Todo: Priority between tree0 and tree1. +TODO: Priority between tree0 and tree1. ***************************************************************************/ @@ -17,12 +18,10 @@ Todo: Priority between tree0 and tree1. #include "changela.h" - - void changela_state::video_start() { - m_memory_devices = std::make_unique(4 * 0x800); /* 0 - not connected, 1,2,3 - RAMs*/ - m_tree_ram = std::make_unique(2 * 0x20); + m_memory_devices = std::make_unique(4 * 0x800); // 0 - not connected, 1,2,3 - RAMs + m_treeram = std::make_unique(2 * 0x20); m_screen->register_screen_bitmap(m_obj0_bitmap); m_screen->register_screen_bitmap(m_river_bitmap); @@ -33,18 +32,17 @@ void changela_state::video_start() m_scanline_timer->adjust(m_screen->time_until_pos(30), 30); save_pointer(NAME(m_memory_devices), 4 * 0x800); - save_pointer(NAME(m_tree_ram), 2 * 0x20); + save_pointer(NAME(m_treeram), 2 * 0x20); } -/************************************************************************** +/********************************* Obj 0 - Sprite Layer +*********************************/ -***************************************************************************/ - -void changela_state::draw_obj0( bitmap_ind16 &bitmap, int sy ) +void changela_state::draw_obj0(bitmap_ind16 &bitmap, int sy) { - uint8_t const *const ROM = memregion("user1")->base(); + uint8_t const *const ROM = m_obj0rom; uint8_t const *const RAM = m_spriteram; for (int sx = 0; sx < 256; sx++) @@ -67,7 +65,7 @@ void changela_state::draw_obj0( bitmap_ind16 &bitmap, int sy ) if (hr) counter ^= 0x0f; uint32_t A8 = ((tile & 0x02) >> 1) ^ ((hr & hs) ^ hs); - uint32_t A7 = ((((vr ^ ((sum & 0x10) >> 4)) & ((vsize & 0x10) >> 4)) ^ 0x01) & (tile & 0x01) ) ^ 0x01; + uint32_t A7 = ((((vr ^ ((sum & 0x10) >> 4)) & ((vsize & 0x10) >> 4)) ^ 0x01) & (tile & 0x01)) ^ 0x01; uint32_t rom_addr = (counter >> 1) | ((sum & 0x0f) << 3) | (A7 << 7) | (A8 << 8) | ((tile >> 2) << 9); if (vr) rom_addr ^= (0x0f << 3); @@ -95,18 +93,17 @@ void changela_state::draw_obj0( bitmap_ind16 &bitmap, int sy ) } } -/************************************************************************** +/********************************* Obj 1 - Text Layer +*********************************/ -***************************************************************************/ - -void changela_state::draw_obj1( bitmap_ind16 &bitmap ) +void changela_state::draw_obj1(bitmap_ind16 &bitmap) { - uint8_t const *const ROM = memregion("gfx2")->base(); + uint8_t const *const ROM = m_obj1rom; uint8_t const *const RAM = m_videoram; - uint8_t reg[4] = { 0 }; /* 4x4-bit registers (U58, U59) */ + uint8_t reg[4] = { 0 }; // 4x4-bit registers (U58, U59) uint8_t attrib = 0; @@ -114,18 +111,18 @@ void changela_state::draw_obj1( bitmap_ind16 &bitmap ) { for (int sx = 0; sx < 256; sx++) { - /* 11 Bits: H1, H3, H4, H5, H6, H7, V3, V4, V5, V6, V7 */ + // 11 Bits: H1, H3, H4, H5, H6, H7, V3, V4, V5, V6, V7 int ram_addr = ((sx & 0xf8) >> 2) | ((sy & 0xf8) << 3); int tile_addr = RAM[ram_addr]; - if (!(RAM[ram_addr + 1] & 0x10) && (sx & 0x04)) /* D4=0 enables latch at U32 */ + if (!(RAM[ram_addr + 1] & 0x10) && (sx & 0x04)) // D4=0 enables latch at U32 attrib = RAM[ram_addr + 1]; uint8_t tile = ROM[(tile_addr << 4) | ((sx & 0x04) >> 2) | ((sy & 0x07) << 1)]; reg[(sx & 0x0c) >> 2] = tile; - int sum = (sx & 0x0f) + (attrib & 0x0f); /* 4-bit adder (U45) */ + int sum = (sx & 0x0f) + (attrib & 0x0f); // 4-bit adder (U45) - /* Multiplexors (U57) */ + // Multiplexers (U57) int c0, c1; if ((sum & 0x03) == 0) { @@ -155,19 +152,18 @@ void changela_state::draw_obj1( bitmap_ind16 &bitmap ) } } -/************************************************************************** +/********************************* River Video Generator +*********************************/ -***************************************************************************/ - -void changela_state::draw_river( bitmap_ind16 &bitmap, int sy ) +void changela_state::draw_river(bitmap_ind16 &bitmap, int sy) { - uint8_t const *const ROM = memregion("user2")->base(); + uint8_t const *const ROM = m_sloperom; uint8_t *const RAM = m_memory_devices.get() + 0x800; - uint8_t const *const TILE_ROM = memregion("gfx1")->base(); + uint8_t const *const TILE_ROM = m_tilerom; uint8_t const *const TILE_RAM = m_memory_devices.get() + 0x1000; - uint8_t const *const PROM = memregion("proms")->base(); + uint8_t const *const PROM = m_proms; int preload = ((sy < 32) ? 1 : 0); @@ -182,16 +178,16 @@ void changela_state::draw_river( bitmap_ind16 &bitmap, int sy ) int hosc = 0; int carry = 0; - /* Update Counters */ + // Update Counters if (sy == 30) m_v_count_river = m_horizon; m_v_count_river = (m_v_count_river + 1) & 0xff; - /* ----- STATE MACHINE ----- */ + // ----- STATE MACHINE ----- for (int i = 0; i < 0x20; i++) { uint8_t curr_state = PROM[i]; - /* Update Counters */ + // Update Counters if (prev_state & 0x80) ram_count = (ram_count + 1) & 0x0f; if ((curr_state & 0x40) && !(prev_state & 0x40)) @@ -205,7 +201,7 @@ void changela_state::draw_river( bitmap_ind16 &bitmap, int sy ) if (prev_state & 0x10) hosc = (math_train[8] << 4) | math_train[9]; - int rom_addr = m_slopeROM_bank | ((m_v_count_river & 0x7e) << 2) | ((rom_count & 0x0e) >> 1); + int rom_addr = m_sloperom_bank | ((m_v_count_river & 0x7e) << 2) | ((rom_count & 0x0e) >> 1); int ram_a5 = ((curr_state & 0x01) & ((curr_state & 0x40) >> 6) & preload) ^ 0x01; int ram_addr = (ram_a5 << 5) | (ram_count << 1) | ((curr_state & 0x20) >> 5); int mux45 = rom_count & 0x01; @@ -239,7 +235,7 @@ void changela_state::draw_river( bitmap_ind16 &bitmap, int sy ) break; } - /* Shift each item down the train */ + // Shift each item down the train if (curr_state & 0x02) { for (int j = 9; j > 0; j--) @@ -262,7 +258,7 @@ void changela_state::draw_river( bitmap_ind16 &bitmap, int sy ) int tile_v = ((math_train[3] & 0x0c) >> 2) | ((math_train[2] & 0x0f) << 2) | ((math_train[1] & 0x07) << 6); int tile_h = (math_train[7] & 0x0f) | ((math_train[6] & 0x0f) << 4) | ((math_train[5] & 0x01) << 8); - /* Burst of 16 10Mhz Clocks */ + // Burst of 16 10Mhz Clocks for (int sx = 0; sx < 16; sx++) { for (int i = 0; i < 2; i++) @@ -272,7 +268,7 @@ void changela_state::draw_river( bitmap_ind16 &bitmap, int sy ) h_count = ((math_train[9] & 0x0f) >> 1) | ((math_train[8] & 0x0f) << 3) | 0x80; tile_h = (tile_h+1) & 0xfff; - /* Skip one count if LSB is high */ + // Skip one count if LSB is high if (((math_train[9] & 0x01) && (tile_h & 0x01))) h_count--; } @@ -301,7 +297,7 @@ void changela_state::draw_river( bitmap_ind16 &bitmap, int sy ) h_count = ((math_train[9] & 0x0f) >> 1) | ((math_train[8] & 0x0f) << 3) | 0x80; tile_h = (tile_h+1) & 0xfff; - /* Skip one count if LSB is high */ + // Skip one count if LSB is high if (((math_train[9] & 0x01) && (tile_h & 0x01))) h_count--; } @@ -323,23 +319,22 @@ void changela_state::draw_river( bitmap_ind16 &bitmap, int sy ) } } -/************************************************************************** +/********************************* Tree Generators +*********************************/ -***************************************************************************/ - -void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) +void changela_state::draw_tree(bitmap_ind16 &bitmap, int sy, int tree_num) { - /* State machine */ - uint8_t const *const ROM = memregion("user2")->base(); + // State machine + uint8_t const *const ROM = m_sloperom; uint8_t *const RAM = m_memory_devices.get() + 0x840 + 0x40 * tree_num; - uint8_t const *const PROM = memregion("proms")->base(); + uint8_t const *const PROM = m_proms; - /* Tree Data */ - uint8_t *const RAM2 = m_tree_ram.get() + 0x20 * tree_num; - uint8_t const *const TILE_ROM = (tree_num ? (memregion("user3")->base() + 0x1000) : (memregion("gfx1")->base() + 0x2000)); - uint8_t const *const TILE_RAM = (tree_num ? (memregion("user3")->base()) : (m_memory_devices.get() + 0x1800)); + // Tree Data + uint8_t *const RAM2 = m_treeram.get() + 0x20 * tree_num; + uint8_t const *const TILE_ROM = (tree_num ? (m_treerom + 0x1000) : (m_tilerom + 0x2000)); + uint8_t const *const TILE_RAM = (tree_num ? (m_treerom) : (m_memory_devices.get() + 0x1800)); int preload = ((sy < 32) ? 1 : 0); @@ -359,7 +354,7 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) int h_count, tile_v, tile_h; int all_ff; - /* Update Counters */ + // Update Counters if (sy == 30) { m_tree_on[tree_num] = 0; @@ -369,12 +364,12 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) if (tree_num == 0) m_v_count_tree = (m_v_count_tree + 1) & 0xff; - /* ----- STATE MACHINE ----- */ + //* ----- STATE MACHINE ----- for (int i = 0; i < 0x20; i++) { uint8_t curr_state = PROM[i]; - /* Update Counters */ + // Update Counters if (prev_state & 0x80) ram_count = (ram_count + 1) & 0x0f; if ((curr_state & 0x40) && !(prev_state & 0x40)) @@ -391,7 +386,7 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) if (prev_state & 0x10) hosc = (math_train[8] << 4) | math_train[9]; - int rom_addr = m_slopeROM_bank | ((m_v_count_tree & 0x7e) << 2) | ((rom_count & 0x0e) >> 1); + int rom_addr = m_sloperom_bank | ((m_v_count_tree & 0x7e) << 2) | ((rom_count & 0x0e) >> 1); int ram_a5 = ((curr_state & 0x01) & ((curr_state & 0x40) >> 6) & preload) ^ 0x01; int ram_addr = (ram_a5 << 5) | (ram_count << 1) | ((curr_state & 0x20) >> 5); int ram2_addr = (ram_count << 1) | ((curr_state & 0x20) >> 5); @@ -401,16 +396,16 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) switch(curr_state) { case 0x01: case 0x09: case 0x19: case 0x0d: case 0x8d: - pre_train[0] = ( mux45 ? ((ROM[rom_addr] & 0xf0) >> 4) : (ROM[rom_addr] & 0x0f) ); + pre_train[0] = (mux45 ? ((ROM[rom_addr] & 0xf0) >> 4) : (ROM[rom_addr] & 0x0f)); break; case 0x0f: case 0x2f: - RAM[ram_addr] = ( mux45 ? ((ROM[rom_addr] & 0xf0) >> 4) : (ROM[rom_addr] & 0x0f) ); + RAM[ram_addr] = (mux45 ? ((ROM[rom_addr] & 0xf0) >> 4) : (ROM[rom_addr] & 0x0f)); break; case 0x4d: case 0x69: case 0x6d: case 0xc5: case 0xcd: pre_train[0] = RAM[ram_addr] & 0x0f; break; case 0xea: case 0xee: - RAM[ram_addr] = ( mux61 ? (pre_train[1]) : ((pre_train[1] + pre_train[2] + carry) & 0x0f) ); + RAM[ram_addr] = (mux61 ? (pre_train[1]) : ((pre_train[1] + pre_train[2] + carry) & 0x0f)); break; default: break; @@ -432,7 +427,7 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) tree_train[0] = RAM2[ram2_addr] = pre_train[0]; break; case 0xea: case 0xee: - math_train[0] = RAM2[ram2_addr] = ( mux82 ? ((tree_train[1] + tree_train[2] + tree_carry) & 0x0f) : (tree_train[1]) ); + math_train[0] = RAM2[ram2_addr] = (mux82 ? ((tree_train[1] + tree_train[2] + tree_carry) & 0x0f) : (tree_train[1])); break; default: break; @@ -461,7 +456,7 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) } } - /* Shift each item down the train */ + // Shift each item down the train if (curr_state & 0x02) { for (int j = 9; j > 0; j--) @@ -483,7 +478,7 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) tile_h = (math_train[7] & 0x0f) | ((math_train[6] & 0x0f) << 4) | ((math_train[5] & 0x01) << 8); all_ff = 1; - /* Burst of 16 10Mhz clocks */ + // Burst of 16 10Mhz clocks for (int sx = 0; sx < 16; sx++) { for (int i = 0; i < 2; i++) @@ -493,7 +488,7 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) h_count = ((math_train[9] & 0x0f) >> 1) | ((math_train[8] & 0x0f) << 3) | 0x80; tile_h = (tile_h+1) & 0xfff; - /* Skip one count if LSB is high */ + // Skip one count if LSB is high if (((math_train[9] & 0x01) && (tile_h & 0x01))) h_count--; } @@ -532,7 +527,7 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) h_count = ((math_train[9] & 0x0f) >> 1) | ((math_train[8] & 0x0f) << 3) | 0x80; tile_h = (tile_h+1) & 0xfff; - /* Skip one count if LSB is high */ + // Skip one count if LSB is high if (((math_train[9] & 0x01) && (tile_h & 0x01))) h_count--; } @@ -562,8 +557,7 @@ void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) } } - /* Tree on only stays high if a pixel that is not 0xf is encountered, - because any non 0xf pixel sets U56 high */ + // Tree on only stays high if a pixel that is not 0xf is encountered, because any non 0xf pixel sets U56 high if (all_ff) m_tree_on[tree_num] = 0; } @@ -620,7 +614,7 @@ TIMER_CALLBACK_MEMBER(changela_state::changela_scanline_callback) { int sy = param; - /* clear the current scanline first */ + // clear the current scanline first const rectangle rect(0, 255, sy, sy); m_river_bitmap.fill(0x00, rect); m_obj0_bitmap.fill(0x00, rect); @@ -632,7 +626,7 @@ TIMER_CALLBACK_MEMBER(changela_state::changela_scanline_callback) draw_tree(m_tree0_bitmap, sy, 0); draw_tree(m_tree1_bitmap, sy, 1); - /* Collision Detection */ + // Collision Detection for (int sx = 1; sx < 256; sx++) { int riv_col; @@ -651,25 +645,25 @@ TIMER_CALLBACK_MEMBER(changela_state::changela_scanline_callback) else prev_col = 0; - if (m_obj0_bitmap.pix(sy, sx) == 0x14) /* Car Outline Color */ + if (m_obj0_bitmap.pix(sy, sx) == 0x14) // Car Outline Color { - /* Tree 0 Collision */ + // Tree 0 Collision if (m_tree0_bitmap.pix(sy, sx) != 0) m_tree0_col = 1; - /* Tree 1 Collision */ + // Tree 1 Collision if (m_tree1_bitmap.pix(sy, sx) != 0) m_tree1_col = 1; - /* Hit Right Bank */ + // Hit Right Bank if (riv_col == 0 && prev_col == 1) m_right_bank_col = 1; - /* Hit Left Bank */ + // Hit Left Bank if (riv_col == 1 && prev_col == 0) m_left_bank_col = 1; - /* Boat Hit Shore */ + // Boat Hit Shore if (riv_col == 1) m_boat_shore_col = 1; } @@ -724,12 +718,12 @@ void changela_state::changela_colors_w(offs_t offset, uint8_t data) int r, g, b; uint32_t c, color_index; - c = (data) | ((offset & 0x01) << 8); /* a0 used as D8 bit input */ + c = (data) | ((offset & 0x01) << 8); //* a0 used as D8 bit input - c ^= 0x1ff; /* active low */ + c ^= 0x1ff; // active low color_index = offset >> 1; - color_index ^= 0x30; /* A4 and A5 lines are negated */ + color_index ^= 0x30; // A4 and A5 lines are negated r = color_table[(c >> 0) & 0x07]; g = color_table[(c >> 3) & 0x07]; @@ -747,11 +741,11 @@ void changela_state::changela_mem_device_select_w(uint8_t data) /* (data & 0x07) possible settings: 0 - not connected (no device) - 1 - ADR1 is 2114 RAM at U59 (state machine()) (accessible range: 0x0000-0x003f) + 1 - ADR1 is 2114 RAM at U59 (state machine) (accessible range: 0x0000-0x003f) 2 - ADR2 is 2128 RAM at U109 (River RAM) (accessible range: 0x0000-0x07ff) - 3 - ADR3 is 2128 RAM at U114 (Tree RAM) (accessible range: 0x0000-0x07ff) + 3 - ADR3 is 2128 RAM at U114 (Tree RAM) (accessible range: 0x0000-0x07ff) 4 - ADR4 is 2732 ROM at U7 (Tree ROM) (accessible range: 0x0000-0x07ff) - 5 - SLOPE is ROM at U44 (state machine()) (accessible range: 0x0000-0x07ff) + 5 - SLOPE is ROM at U44 (state machine) (accessible range: 0x0000-0x07ff) */ } @@ -775,7 +769,7 @@ uint8_t changela_state::changela_mem_device_r(offs_t offset) void changela_state::changela_slope_rom_addr_hi_w(uint8_t data) { - m_slopeROM_bank = (data & 0x03) << 9; + m_sloperom_bank = (data & 0x03) << 9; } void changela_state::changela_slope_rom_addr_lo_w(uint8_t data) -- cgit v1.2.3