Previous 199869 Revisions Next

r31519 Tuesday 5th August, 2014 at 17:54:11 UTC by hap
changed RP5H01 from read8/write8 to read_line/write_line + removed unneeded enable/disable in drivers
[src/emu/machine]rp5h01.c rp5h01.h
[src/mame/drivers]nss.c
[src/mame/machine]playch10.c

trunk/src/emu/machine/rp5h01.c
r31518r31519
11/***************************************************************************
22
3    RP5H01
3    RP5H01 - Ricoh 64x1bit PROM with 6/7-bit counter
44
55    TODO:
66    - follow the datasheet better (all dumps presumably needs to be redone
r31518r31519
5959   m_counter_mode = COUNTER_MODE_6_BITS;
6060   m_enabled = 0;
6161   m_old_reset = -1;
62   m_old_clock = -1;
62   m_old_clock = 0;
6363}
6464
6565
r31518r31519
7171    enable_w
7272-------------------------------------------------*/
7373
74WRITE8_MEMBER( rp5h01_device::enable_w )
74WRITE_LINE_MEMBER( rp5h01_device::enable_w )
7575{
7676   /* process the /CE signal and enable/disable the IC */
77   m_enabled = (data == 0) ? 1 : 0;
77   m_enabled = state ? 0 : 1;
7878}
7979
8080/*-------------------------------------------------
8181    reset_w
8282-------------------------------------------------*/
8383
84WRITE8_MEMBER( rp5h01_device::reset_w )
84WRITE_LINE_MEMBER( rp5h01_device::reset_w )
8585{
86   int newstate = (data == 0) ? 0 : 1;
86   state = !state;
8787
8888   /* if it's not enabled, ignore */
8989   if (!m_enabled)
9090      return;
9191
9292   /* now look for a 0->1 transition */
93   if (m_old_reset == 0 && newstate == 1)
93   if (!m_old_reset && state)
9494   {
9595      /* reset the counter */
9696      m_counter = 0;
9797   }
9898
9999   /* update the pin */
100   m_old_reset = newstate;
100   m_old_reset = state;
101101}
102102
103103/*-------------------------------------------------
104104    cs_w
105105-------------------------------------------------*/
106106
107WRITE8_MEMBER( rp5h01_device::cs_w )
107WRITE_LINE_MEMBER( rp5h01_device::cs_w )
108108{
109109   /* if it's not enabled, ignore */
110110   if (!m_enabled)
111111      return;
112112
113   if (data == 1)
113   if (state)
114114   {
115115      /* reset the counter */
116116      m_counter = 0;
r31518r31519
121121    clock_w
122122-------------------------------------------------*/
123123
124WRITE8_MEMBER( rp5h01_device::clock_w )
124WRITE_LINE_MEMBER( rp5h01_device::clock_w )
125125{
126   int newstate = (data == 0) ? 0 : 1;
127
128126   /* if it's not enabled, ignore */
129127   if (!m_enabled)
130128      return;
131129
132130   /* now look for a 1->0 transition */
133   if (m_old_clock == 1 && newstate == 0)
131   if (m_old_clock && !state)
134132   {
135133      /* increment the counter, and mask it with the mode */
136134      m_counter++;
137135   }
138136
139137   /* update the pin */
140   m_old_clock = newstate;
138   m_old_clock = state;
141139}
142140
143141/*-------------------------------------------------
144142    test_w
145143-------------------------------------------------*/
146144
147WRITE8_MEMBER( rp5h01_device::test_w )
145WRITE_LINE_MEMBER( rp5h01_device::test_w )
148146{
149147   /* if it's not enabled, ignore */
150148   if (!m_enabled)
151149      return;
152150
153151   /* 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;
155153}
156154
157155/*-------------------------------------------------
158156    counter_r
159157-------------------------------------------------*/
160158
161READ8_MEMBER( rp5h01_device::counter_r )
159READ_LINE_MEMBER( rp5h01_device::counter_r )
162160{
163161   /* if it's not enabled, ignore */
164162   if (!m_enabled)
165      return 0; /* ? (should be high impedance) */
163      return 1; /* high impedance */
166164
167165   /* return A5 */
168166   return (m_counter >> 5) & 1;
r31518r31519
172170    data_r
173171-------------------------------------------------*/
174172
175READ8_MEMBER( rp5h01_device::data_r )
173READ_LINE_MEMBER( rp5h01_device::data_r )
176174{
177   int byte, bit;
178
179175   /* if it's not enabled, ignore */
180176   if (!m_enabled)
181      return 0; /* ? (should be high impedance) */
177      return 1; /* high impedance */
182178
183179   /* 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);
186182
187183   /* return the data */
188184   return (m_data[byte] >> bit) & 1;
trunk/src/emu/machine/rp5h01.h
r31518r31519
11/***************************************************************************
22
3    RP5H01
3    RP5H01 - Ricoh 64x1bit PROM with 6/7-bit counter
44
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
514
615***************************************************************************/
716
r31518r31519
2837public:
2938   rp5h01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
3039
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 */
3847
3948protected:
4049   // device-level overrides
trunk/src/mame/machine/playch10.c
r31518r31519
2626   m_MMC2_bank_latch[0] = m_MMC2_bank_latch[1] = 0xfe;
2727
2828   /* 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);
3433
3534   pc10_set_mirroring(m_mirroring);
3635}
r31518r31519
160159   /* we only support a single cart connected at slot 0 */
161160   if (m_cart_sel == 0)
162161   {
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 */
167164   }
168165   return data;
169166}
r31518r31519
173170   /* we only support a single cart connected at slot 0 */
174171   if (m_cart_sel == 0)
175172   {
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 */
181176   }
182177}
183178
trunk/src/mame/drivers/nss.c
r31518r31519
304304      m_rp5h01(*this,"rp5h01"),
305305      m_screen(*this, "screen"),
306306      m_palette(*this, "palette")
307      { }
307   { }
308308
309309   required_device<m50458_device> m_m50458;
310310   required_device<s3520cf_device> m_s3520cf;
r31518r31519
470470
471471   if (m_cart_sel == 0)
472472   {
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 */
477475   }
478   else
479      m_rp5h01->enable_w(space, 0, 1);
480476
481477   return data;
482478}
r31518r31519
485481{
486482   if (m_cart_sel == 0)
487483   {
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);
493487   }
494   else
495      m_rp5h01->enable_w(space, 0, 1);
496488
497489   ioport("EEPROMOUT")->write(data, 0xff);
498490}
r31518r31519
803795   m_maincpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
804796   m_soundcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
805797
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
806804   m_game_over_flag = 1;
807805   m_joy_flag = 1;
808806}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team