trunk/src/emu/machine/rp5h01.c
| r31518 | r31519 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | RP5H01 |
| 3 | RP5H01 - Ricoh 64x1bit PROM with 6/7-bit counter |
| 4 | 4 | |
| 5 | 5 | TODO: |
| 6 | 6 | - follow the datasheet better (all dumps presumably needs to be redone |
| r31518 | r31519 | |
| 59 | 59 | m_counter_mode = COUNTER_MODE_6_BITS; |
| 60 | 60 | m_enabled = 0; |
| 61 | 61 | m_old_reset = -1; |
| 62 | | m_old_clock = -1; |
| 62 | m_old_clock = 0; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
| r31518 | r31519 | |
| 71 | 71 | enable_w |
| 72 | 72 | -------------------------------------------------*/ |
| 73 | 73 | |
| 74 | | WRITE8_MEMBER( rp5h01_device::enable_w ) |
| 74 | WRITE_LINE_MEMBER( rp5h01_device::enable_w ) |
| 75 | 75 | { |
| 76 | 76 | /* process the /CE signal and enable/disable the IC */ |
| 77 | | m_enabled = (data == 0) ? 1 : 0; |
| 77 | m_enabled = state ? 0 : 1; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /*------------------------------------------------- |
| 81 | 81 | reset_w |
| 82 | 82 | -------------------------------------------------*/ |
| 83 | 83 | |
| 84 | | WRITE8_MEMBER( rp5h01_device::reset_w ) |
| 84 | WRITE_LINE_MEMBER( rp5h01_device::reset_w ) |
| 85 | 85 | { |
| 86 | | int newstate = (data == 0) ? 0 : 1; |
| 86 | state = !state; |
| 87 | 87 | |
| 88 | 88 | /* if it's not enabled, ignore */ |
| 89 | 89 | if (!m_enabled) |
| 90 | 90 | return; |
| 91 | 91 | |
| 92 | 92 | /* now look for a 0->1 transition */ |
| 93 | | if (m_old_reset == 0 && newstate == 1) |
| 93 | if (!m_old_reset && state) |
| 94 | 94 | { |
| 95 | 95 | /* reset the counter */ |
| 96 | 96 | m_counter = 0; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /* update the pin */ |
| 100 | | m_old_reset = newstate; |
| 100 | m_old_reset = state; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /*------------------------------------------------- |
| 104 | 104 | cs_w |
| 105 | 105 | -------------------------------------------------*/ |
| 106 | 106 | |
| 107 | | WRITE8_MEMBER( rp5h01_device::cs_w ) |
| 107 | WRITE_LINE_MEMBER( rp5h01_device::cs_w ) |
| 108 | 108 | { |
| 109 | 109 | /* if it's not enabled, ignore */ |
| 110 | 110 | if (!m_enabled) |
| 111 | 111 | return; |
| 112 | 112 | |
| 113 | | if (data == 1) |
| 113 | if (state) |
| 114 | 114 | { |
| 115 | 115 | /* reset the counter */ |
| 116 | 116 | m_counter = 0; |
| r31518 | r31519 | |
| 121 | 121 | clock_w |
| 122 | 122 | -------------------------------------------------*/ |
| 123 | 123 | |
| 124 | | WRITE8_MEMBER( rp5h01_device::clock_w ) |
| 124 | WRITE_LINE_MEMBER( rp5h01_device::clock_w ) |
| 125 | 125 | { |
| 126 | | int newstate = (data == 0) ? 0 : 1; |
| 127 | | |
| 128 | 126 | /* if it's not enabled, ignore */ |
| 129 | 127 | if (!m_enabled) |
| 130 | 128 | return; |
| 131 | 129 | |
| 132 | 130 | /* now look for a 1->0 transition */ |
| 133 | | if (m_old_clock == 1 && newstate == 0) |
| 131 | if (m_old_clock && !state) |
| 134 | 132 | { |
| 135 | 133 | /* increment the counter, and mask it with the mode */ |
| 136 | 134 | m_counter++; |
| 137 | 135 | } |
| 138 | 136 | |
| 139 | 137 | /* update the pin */ |
| 140 | | m_old_clock = newstate; |
| 138 | m_old_clock = state; |
| 141 | 139 | } |
| 142 | 140 | |
| 143 | 141 | /*------------------------------------------------- |
| 144 | 142 | test_w |
| 145 | 143 | -------------------------------------------------*/ |
| 146 | 144 | |
| 147 | | WRITE8_MEMBER( rp5h01_device::test_w ) |
| 145 | WRITE_LINE_MEMBER( rp5h01_device::test_w ) |
| 148 | 146 | { |
| 149 | 147 | /* if it's not enabled, ignore */ |
| 150 | 148 | if (!m_enabled) |
| 151 | 149 | return; |
| 152 | 150 | |
| 153 | 151 | /* process the test signal and change the counter mode */ |
| 154 | | m_counter_mode = (data == 0) ? COUNTER_MODE_6_BITS : COUNTER_MODE_7_BITS; |
| 152 | m_counter_mode = (state) ? COUNTER_MODE_7_BITS : COUNTER_MODE_6_BITS; |
| 155 | 153 | } |
| 156 | 154 | |
| 157 | 155 | /*------------------------------------------------- |
| 158 | 156 | counter_r |
| 159 | 157 | -------------------------------------------------*/ |
| 160 | 158 | |
| 161 | | READ8_MEMBER( rp5h01_device::counter_r ) |
| 159 | READ_LINE_MEMBER( rp5h01_device::counter_r ) |
| 162 | 160 | { |
| 163 | 161 | /* if it's not enabled, ignore */ |
| 164 | 162 | if (!m_enabled) |
| 165 | | return 0; /* ? (should be high impedance) */ |
| 163 | return 1; /* high impedance */ |
| 166 | 164 | |
| 167 | 165 | /* return A5 */ |
| 168 | 166 | return (m_counter >> 5) & 1; |
| r31518 | r31519 | |
| 172 | 170 | data_r |
| 173 | 171 | -------------------------------------------------*/ |
| 174 | 172 | |
| 175 | | READ8_MEMBER( rp5h01_device::data_r ) |
| 173 | READ_LINE_MEMBER( rp5h01_device::data_r ) |
| 176 | 174 | { |
| 177 | | int byte, bit; |
| 178 | | |
| 179 | 175 | /* if it's not enabled, ignore */ |
| 180 | 176 | if (!m_enabled) |
| 181 | | return 0; /* ? (should be high impedance) */ |
| 177 | return 1; /* high impedance */ |
| 182 | 178 | |
| 183 | 179 | /* get the byte offset and bit offset */ |
| 184 | | byte = (m_counter & m_counter_mode) >> 3; |
| 185 | | bit = 7 - (m_counter & 7); |
| 180 | int byte = (m_counter & m_counter_mode) >> 3; |
| 181 | int bit = 7 - (m_counter & 7); |
| 186 | 182 | |
| 187 | 183 | /* return the data */ |
| 188 | 184 | return (m_data[byte] >> bit) & 1; |
trunk/src/emu/machine/rp5h01.h
| r31518 | r31519 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | RP5H01 |
| 3 | RP5H01 - Ricoh 64x1bit PROM with 6/7-bit counter |
| 4 | 4 | |
| 5 | **************************************************************************** |
| 6 | ___________ |
| 7 | DATA 1 |* | 8 COUNTER OUT |
| 8 | | | |
| 9 | _CE/Vpp 2 | RP5H01 | 7 RESET |
| 10 | | RF5H01 | |
| 11 | Vcc 3 | | 6 DATA CLOCK |
| 12 | | | |
| 13 | GND 4 |___________| 5 TEST |
| 5 | 14 | |
| 6 | 15 | ***************************************************************************/ |
| 7 | 16 | |
| r31518 | r31519 | |
| 28 | 37 | public: |
| 29 | 38 | rp5h01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 30 | 39 | |
| 31 | | DECLARE_WRITE8_MEMBER( enable_w ); /* /CE */ |
| 32 | | DECLARE_WRITE8_MEMBER( reset_w ); /* RESET */ |
| 33 | | DECLARE_WRITE8_MEMBER( cs_w ); /* CS */ |
| 34 | | DECLARE_WRITE8_MEMBER( clock_w ); /* DATA CLOCK (active low) */ |
| 35 | | DECLARE_WRITE8_MEMBER( test_w ); /* TEST */ |
| 36 | | DECLARE_READ8_MEMBER( counter_r ); /* COUNTER OUT */ |
| 37 | | DECLARE_READ8_MEMBER( data_r ); /* DATA */ |
| 40 | DECLARE_WRITE_LINE_MEMBER( enable_w ); /* /CE */ |
| 41 | DECLARE_WRITE_LINE_MEMBER( reset_w ); /* RESET */ |
| 42 | DECLARE_WRITE_LINE_MEMBER( cs_w ); /* CS */ |
| 43 | DECLARE_WRITE_LINE_MEMBER( clock_w ); /* DATA CLOCK (active low) */ |
| 44 | DECLARE_WRITE_LINE_MEMBER( test_w ); /* TEST */ |
| 45 | DECLARE_READ_LINE_MEMBER( counter_r ); /* COUNTER OUT */ |
| 46 | DECLARE_READ_LINE_MEMBER( data_r ); /* DATA */ |
| 38 | 47 | |
| 39 | 48 | protected: |
| 40 | 49 | // device-level overrides |
trunk/src/mame/machine/playch10.c
| r31518 | r31519 | |
| 26 | 26 | m_MMC2_bank_latch[0] = m_MMC2_bank_latch[1] = 0xfe; |
| 27 | 27 | |
| 28 | 28 | /* reset the security chip */ |
| 29 | | address_space &space = generic_space(); |
| 30 | | m_rp5h01->enable_w(space, 0, 0); |
| 31 | | m_rp5h01->reset_w(space, 0, 0); |
| 32 | | m_rp5h01->reset_w(space, 0, 1); |
| 33 | | m_rp5h01->enable_w(space, 0, 1); |
| 29 | m_rp5h01->enable_w(1); |
| 30 | m_rp5h01->enable_w(0); |
| 31 | m_rp5h01->reset_w(0); |
| 32 | m_rp5h01->reset_w(1); |
| 34 | 33 | |
| 35 | 34 | pc10_set_mirroring(m_mirroring); |
| 36 | 35 | } |
| r31518 | r31519 | |
| 160 | 159 | /* we only support a single cart connected at slot 0 */ |
| 161 | 160 | if (m_cart_sel == 0) |
| 162 | 161 | { |
| 163 | | m_rp5h01->enable_w(space, 0, 0); |
| 164 | | data |= ((~m_rp5h01->counter_r(space, 0)) << 4) & 0x10; /* D4 */ |
| 165 | | data |= ((m_rp5h01->data_r(space, 0)) << 3) & 0x08; /* D3 */ |
| 166 | | m_rp5h01->enable_w(space, 0, 1); |
| 162 | data |= ((~m_rp5h01->counter_r()) << 4) & 0x10; /* D4 */ |
| 163 | data |= (m_rp5h01->data_r() << 3) & 0x08; /* D3 */ |
| 167 | 164 | } |
| 168 | 165 | return data; |
| 169 | 166 | } |
| r31518 | r31519 | |
| 173 | 170 | /* we only support a single cart connected at slot 0 */ |
| 174 | 171 | if (m_cart_sel == 0) |
| 175 | 172 | { |
| 176 | | m_rp5h01->enable_w(space, 0, 0); |
| 177 | | m_rp5h01->test_w(space, 0, data & 0x10); /* D4 */ |
| 178 | | m_rp5h01->clock_w(space, 0, data & 0x08); /* D3 */ |
| 179 | | m_rp5h01->reset_w(space, 0, ~data & 0x01); /* D0 */ |
| 180 | | m_rp5h01->enable_w(space, 0, 1); |
| 173 | m_rp5h01->test_w(data & 0x10); /* D4 */ |
| 174 | m_rp5h01->clock_w(data & 0x08); /* D3 */ |
| 175 | m_rp5h01->reset_w(~data & 0x01); /* D0 */ |
| 181 | 176 | } |
| 182 | 177 | } |
| 183 | 178 | |
trunk/src/mame/drivers/nss.c
| r31518 | r31519 | |
| 304 | 304 | m_rp5h01(*this,"rp5h01"), |
| 305 | 305 | m_screen(*this, "screen"), |
| 306 | 306 | m_palette(*this, "palette") |
| 307 | | { } |
| 307 | { } |
| 308 | 308 | |
| 309 | 309 | required_device<m50458_device> m_m50458; |
| 310 | 310 | required_device<s3520cf_device> m_s3520cf; |
| r31518 | r31519 | |
| 470 | 470 | |
| 471 | 471 | if (m_cart_sel == 0) |
| 472 | 472 | { |
| 473 | | m_rp5h01->enable_w(space, 0, 0); |
| 474 | | data |= ((~m_rp5h01->counter_r(space, 0)) << 4) & 0x10; /* D4 */ |
| 475 | | data |= ((m_rp5h01->data_r(space, 0)) << 3) & 0x08; /* D3 */ |
| 476 | | m_rp5h01->enable_w(space, 0, 1); |
| 473 | data |= ((~m_rp5h01->counter_r()) << 4) & 0x10; /* D4 */ |
| 474 | data |= (m_rp5h01->data_r() << 3) & 0x08; /* D3 */ |
| 477 | 475 | } |
| 478 | | else |
| 479 | | m_rp5h01->enable_w(space, 0, 1); |
| 480 | 476 | |
| 481 | 477 | return data; |
| 482 | 478 | } |
| r31518 | r31519 | |
| 485 | 481 | { |
| 486 | 482 | if (m_cart_sel == 0) |
| 487 | 483 | { |
| 488 | | m_rp5h01->enable_w(space, 0, 0); |
| 489 | | m_rp5h01->test_w(space, 0, data & 0x10); /* D4 */ |
| 490 | | m_rp5h01->clock_w(space, 0, data & 0x08); /* D3 */ |
| 491 | | m_rp5h01->cs_w(space, 0, ~data & 0x01); |
| 492 | | m_rp5h01->enable_w(space, 0, 1); |
| 484 | m_rp5h01->test_w(data & 0x10); /* D4 */ |
| 485 | m_rp5h01->clock_w(data & 0x08); /* D3 */ |
| 486 | m_rp5h01->cs_w(~data & 0x01); |
| 493 | 487 | } |
| 494 | | else |
| 495 | | m_rp5h01->enable_w(space, 0, 1); |
| 496 | 488 | |
| 497 | 489 | ioport("EEPROMOUT")->write(data, 0xff); |
| 498 | 490 | } |
| r31518 | r31519 | |
| 803 | 795 | m_maincpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 804 | 796 | m_soundcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 805 | 797 | |
| 798 | /* reset the security chip */ |
| 799 | m_rp5h01->enable_w(1); |
| 800 | m_rp5h01->enable_w(0); |
| 801 | m_rp5h01->reset_w(0); |
| 802 | m_rp5h01->reset_w(1); |
| 803 | |
| 806 | 804 | m_game_over_flag = 1; |
| 807 | 805 | m_joy_flag = 1; |
| 808 | 806 | } |