Previous 199869 Revisions Next

r20327 Friday 18th January, 2013 at 23:37:36 UTC by hap
improved steering wheel
[src/mame/drivers]imolagp.c

trunk/src/mame/drivers/imolagp.c
r20326r20327
55TODO:
66- document remaining dips
77- need better mappings for shifter, currently 3 buttons
8- improve analog steering
9- correct timing (cpu and video) - see sprites disappear partially
10- vreg[0xf] autosteering
8- cpu/audio clocks, the XTAL on pcb is unlabeled
9- correct video timing, see sprites disappear partially
10- vreg[0xf] autosteering, the car should probably only auto-steer when
11  it gets on the grass(road edges) at high speed. How does the hardware
12  know the sprite position then?
1113- verify colors
1214
1315========================================
r20326r20327
8991   imolagp_state(const machine_config &mconfig, device_type type, const char *tag)
9092      : driver_device(mconfig, type, tag),
9193      m_maincpu(*this, "maincpu"),
92      m_slavecpu(*this, "slave")
94      m_slavecpu(*this, "slave"),
95      m_steer_pot_timer(*this, "pot"),
96      m_steer_inp(*this, "STEER")
9397   { }
9498
9599   required_device<cpu_device> m_maincpu;
96100   required_device<cpu_device> m_slavecpu;
101   required_device<timer_device> m_steer_pot_timer;
102   required_ioport m_steer_inp;
97103
98104   UINT8 m_videoram[2][0x4000]; // 2 layers of 16KB
99105   UINT8 m_comms_latch[2];
r20326r20327
102108   UINT8 m_scroll;
103109   UINT8 m_steerlatch;
104110   UINT8 m_draw_mode;
105   UINT8 m_oldsteer;
106111
107112   DECLARE_WRITE8_MEMBER(transmit_data_w);
108113   DECLARE_READ8_MEMBER(trigger_slave_nmi_r);
r20326r20327
115120   DECLARE_WRITE8_MEMBER(vreg_data_w);
116121   DECLARE_CUSTOM_INPUT_MEMBER(imolagp_steerlatch_r);
117122   INTERRUPT_GEN_MEMBER(slave_vblank_irq);
123   TIMER_DEVICE_CALLBACK_MEMBER(imolagp_pot_callback);
118124
119125   virtual void machine_start();
120126   virtual void machine_reset();
r20326r20327
133139void imolagp_state::palette_init()
134140{
135141   // palette seems like 3bpp + intensity
142   // this still needs to be verified
136143   for (int i = 0; i < 8; i++)
137144   {
138145      palette_set_color_rgb(machine(), i*4+0, 0, 0, 0);
r20326r20327
184191
185192/***************************************************************************
186193
194  Interrupts
195
196***************************************************************************/
197
198TIMER_DEVICE_CALLBACK_MEMBER(imolagp_state::imolagp_pot_callback)
199{
200   int steer = m_steer_inp->read();
201   if (steer & 0x7f)
202   {
203      if (~steer & 0x80)
204      {
205         // shift register when steering left
206         steer = -steer;
207         m_steerlatch = (m_steerlatch << 1) | (~m_steerlatch >> 1 & 1);
208      }
209     
210      // steering speed is determined by timer period
211      // these values(in usec) may need tweaking:
212      const int base = 6500;
213      const int range = 100000;
214      m_steer_pot_timer->adjust(attotime::from_usec(base + range * (1.0 / (double)(steer & 0x7f))));
215      m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
216   }
217   else
218      m_steer_pot_timer->adjust(attotime::from_msec(20));
219}
220
221INTERRUPT_GEN_MEMBER(imolagp_state::slave_vblank_irq)
222{
223   m_scroll = m_vreg[0xe]; // latch scroll
224   device.execute().set_input_line(0, HOLD_LINE);
225}
226
227
228
229/***************************************************************************
230
187231  I/O and Memory Maps
188232
189233***************************************************************************/
190234
191235/* The master CPU transmits data to the slave CPU one word at a time using a rapid sequence of triggered NMIs.
192 * The slave CPU pauses as it enters its irq, awaiting this burst of data.
236 * The slave CPU pauses as it enters its vblank irq, awaiting this burst of data.
193237 * Handling the NMI takes more time than triggering the NMI, implying that the slave CPU either runs at
194238 * a higher clock, or has a way to force the main CPU to wait.
195239 */
r20326r20327
238282
239283READ8_MEMBER(imolagp_state::vreg_data_r)
240284{
285   // auto-steer related
241286   return 0;
242287   //return 0xf7; // -> go left?
243288   //return 0x17; // it checks for this too
r20326r20327
388433   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
389434
390435   PORT_START("STEER")
391   PORT_BIT( 0x0f, 0x00, IPT_DIAL ) PORT_SENSITIVITY(100) PORT_KEYDELTA(1)
436   PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_MINMAX(0x01, 0xff) PORT_SENSITIVITY(100) PORT_KEYDELTA(24)
392437INPUT_PORTS_END
393438
394439
r20326r20327
417462
418463***************************************************************************/
419464
420static TIMER_DEVICE_CALLBACK ( imolagp_nmi_cb )
465void imolagp_state::machine_start()
421466{
422   imolagp_state *state = timer.machine().driver_data<imolagp_state>();
423   int newsteer = timer.machine().root_device().ioport("STEER")->read() & 0xf;
424   if (newsteer != state->m_oldsteer)
425   {
426      if ((newsteer - state->m_oldsteer) & 0x8)
427      {
428         // shift
429         state->m_steerlatch = (state->m_steerlatch << 1) | (~state->m_steerlatch >> 1 & 1);
430         state->m_oldsteer = (state->m_oldsteer - 1) & 0xf;
431      }
432      else
433      {
434         state->m_oldsteer = (state->m_oldsteer + 1) & 0xf;
435      }
436      state->m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
437   }
467   save_item(NAME(m_vcontrol));
468   save_item(NAME(m_vreg));
469   save_item(NAME(m_scroll));
470   save_item(NAME(m_steerlatch));
471   save_item(NAME(m_draw_mode));
472   save_item(NAME(m_comms_latch));
438473}
439474
440INTERRUPT_GEN_MEMBER(imolagp_state::slave_vblank_irq)
475void imolagp_state::machine_reset()
441476{
442   m_scroll = m_vreg[0xe]; // latch scroll
443   device.execute().set_input_line(0, HOLD_LINE);
477   // reset steering wheel
478   m_steerlatch = 0;
479   m_steer_pot_timer->adjust(attotime::from_msec(20));
444480}
445481
446482
r20326r20327
455491   DEVCB_NULL
456492};
457493
458
459void imolagp_state::machine_start()
460{
461   save_item(NAME(m_vcontrol));
462   save_item(NAME(m_vreg));
463   save_item(NAME(m_scroll));
464   save_item(NAME(m_steerlatch));
465   save_item(NAME(m_draw_mode));
466   save_item(NAME(m_oldsteer));
467   save_item(NAME(m_comms_latch));
468}
469
470void imolagp_state::machine_reset()
471{
472}
473
474494static MACHINE_CONFIG_START( imolagp, imolagp_state )
475495
476496   /* basic machine hardware */
r20326r20327
478498   MCFG_CPU_PROGRAM_MAP(imolagp_master_map)
479499   MCFG_CPU_IO_MAP(imolagp_master_io)
480500   MCFG_CPU_VBLANK_INT_DRIVER("screen", imolagp_state, irq0_line_hold)
481   MCFG_TIMER_ADD_PERIODIC("pot_irq", imolagp_nmi_cb, attotime::from_hz(60*3))
501   MCFG_TIMER_DRIVER_ADD("pot", imolagp_state, imolagp_pot_callback) // maincpu nmi
482502
483503   MCFG_CPU_ADD("slave", Z80, 4000000) // ?
484504   MCFG_CPU_PROGRAM_MAP(imolagp_slave_map)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team