Previous 199869 Revisions Next

r33062 Thursday 30th October, 2014 at 01:02:03 UTC by hap
ufo21 works
[src/mame/drivers]segaufo.c

trunk/src/mame/drivers/segaufo.c
r241573r241574
3737
3838
3939  TODO:
40  - make the other games work (for now only newufo+clones work)
40  - why doesn't ufo800 work?
4141  - add layout
42  - add dipswitches
43  - add upd sound for ufo21
4244
4345***************************************************************************/
4446
r241573r241574
6264#define MOTOR_SPEED     100
6365
6466// crane size (stepper motor range)
65// note: the game expects this to be around 350 steps per quarter rotation
67// note: UFO board/EX board expects this to be around 350 steps per quarter rotation
6668#define CRANE_SIZE      350
6769
6870
r241573r241574
102104   DECLARE_WRITE_LINE_MEMBER(pit_out1);
103105   DECLARE_WRITE_LINE_MEMBER(pit_out2);
104106   DECLARE_WRITE_LINE_MEMBER(ym3438_irq);
107   DECLARE_READ8_MEMBER(ufo_0_r) { return 0; }
105108   DECLARE_READ8_MEMBER(crane_limits_r);
109   DECLARE_READ8_MEMBER(ex_crane_limits_r);
110   DECLARE_READ8_MEMBER(ex_crane_open_r);
106111   DECLARE_WRITE8_MEMBER(stepper_w);
112   DECLARE_WRITE8_MEMBER(ex_stepper_w);
107113   DECLARE_WRITE8_MEMBER(cp_lamps_w);
108114   DECLARE_WRITE8_MEMBER(cp_digits_w);
109115   DECLARE_WRITE8_MEMBER(crane_xyz_w);
116   DECLARE_WRITE8_MEMBER(ex_crane_xyz_w);
110117   DECLARE_WRITE8_MEMBER(ufo_lamps_w);
111118   
112119   virtual void machine_reset();
r241573r241574
185192}
186193
187194
195/* generic / UFO board handlers */
196
188197WRITE8_MEMBER(ufo_state::stepper_w)
189198{
190199   for (int p = 0; p < 2; p++)
r241573r241574
283292      ret ^= 0x40;
284293   
285294   // d7: prize sensor (mirror?)
286   ret |= (ioport(p ? "P2" : "P1")->read() & 0x80);
295   ret |= (ioport(p ? "IN2" : "IN1")->read() & 0x80);
287296
288297   return ret;
289298}
290299
291300
301/* EX board specific handlers */
292302
303WRITE8_MEMBER(ufo_state::ex_stepper_w)
304{
305   // stepper motor sequence is: 6 c 9 3 6 c 9 3..
306   // which means d0 and d3 are swapped when compared with UFO board hardware
307   stepper_w(space, offset, BITSWAP8(data,4,6,5,7,0,2,1,3));
308}
309
310WRITE8_MEMBER(ufo_state::ex_crane_xyz_w)
311{
312   int p = offset & 1;
313   
314   // more straightforward setup than on UFO board hardware
315   // d0: move left
316   // d1: move right
317   // d2: move back
318   // d3: move front
319   // d4: move down
320   // d5: move up
321   for (int i = 0; i < 3; i++)
322   {
323      int bits = data >> (i*2) & 3;
324      m_player[p].motor[i].running = (bits == 1 || bits == 2) ? 1 : 0;
325      m_player[p].motor[i].direction = bits & 2;
326   }
327}
328
329
330READ8_MEMBER(ufo_state::ex_crane_limits_r)
331{
332   int p = offset & 1;
333   UINT8 ret = 0xf0;
334
335   // d0: left limit sw (invert)
336   // d1: right limit sw (invert)
337   // d2: back limit sw (invert)
338   // d3: front limit sw (invert)
339   // d4: ..
340   // d5: down limit sw
341   // d6: up limit sw
342   for (int i = 0; i < 3; i++)
343   {
344      int shift = (i*2) + (i == 2);
345      ret ^= (m_player[p].motor[i].position >= 1) << (shift + 0);
346      ret ^= (m_player[p].motor[i].position <= 0) << (shift + 1);
347   }
348   
349   // d4: crane open or closed sensor
350   // d7: crane open or closed sensor (another one?)
351   if (m_player[p].motor[3].position >= 0.97)
352      ret ^= 0x10;
353   if (m_player[p].motor[3].position <= 0.03)
354      ret ^= 0x80;
355   
356   return ret;
357}
358
359READ8_MEMBER(ufo_state::ex_crane_open_r)
360{
361   // d0-d3: p1, d4-d7: p2
362   UINT8 ret = 0xff;
363   
364   for (int p = 0; p < 2; p++)
365   {
366      // unlike ex_crane_limits_r, this sensor can determine whether the crane is open or closed
367      if (m_player[p].motor[3].position >= 0.97)
368         ret ^= (1 << (p*4));
369      if (m_player[p].motor[3].position <= 0.03)
370         ret ^= (2 << (p*4));
371     
372      // d2,d3: ?
373   }
374   
375   return ret;
376}
377
378
379/* memory maps */
380
293381static ADDRESS_MAP_START( ufo_map, AS_PROGRAM, 8, ufo_state )
294382   AM_RANGE(0x0000, 0xbfff) AM_ROM
295383   AM_RANGE(0xe000, 0xffff) AM_RAM
r241573r241574
300388   ADDRESS_MAP_GLOBAL_MASK(0xff)
301389   AM_RANGE(0x00, 0x03) AM_DEVREADWRITE("pit", pit8254_device, read, write)
302390   AM_RANGE(0x40, 0x43) AM_DEVREADWRITE("ym", ym3438_device, read, write)
303   AM_RANGE(0x80, 0x8f) AM_DEVREADWRITE("io1", sega_315_5296_device, read, write)
304   AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE("io2", sega_315_5296_device, read, write)
391   AM_RANGE(0x80, 0xbf) AM_DEVREADWRITE("io1", sega_315_5296_device, read, write)
392   AM_RANGE(0xc0, 0xff) AM_DEVREADWRITE("io2", sega_315_5296_device, read, write)
305393ADDRESS_MAP_END
306394
307395
r241573r241574
313401***************************************************************************/
314402
315403static INPUT_PORTS_START( newufo )
316   PORT_START("P1")
404   PORT_START("IN1")
317405   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_NAME("P1 Coin 1")
318406   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_NAME("P1 Coin 2")
319407   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("P1 Test")
r241573r241574
323411   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )
324412   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Prize Fell")
325413
326   PORT_START("P2")
414   PORT_START("IN2")
327415   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_NAME("P2 Coin 1")
328416   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN4 ) PORT_NAME("P2 Coin 2")
329417   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P2 Test") PORT_CODE(KEYCODE_F1)
r241573r241574
389477static INPUT_PORTS_START( ufomini )
390478   PORT_INCLUDE( newufo )
391479
392   PORT_MODIFY("P2")
480   PORT_MODIFY("IN2")
393481   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
394482INPUT_PORTS_END
395483
396484
485static INPUT_PORTS_START( ufo21 )
486   PORT_START("IN1")
487   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Test Button")
488   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P1 Service Coin")
489   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_NAME("P1 Coin 1")
490   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
491   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
492   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("P2 Service Coin")
493   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_NAME("P2 Coin 1")
494   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
397495
496   PORT_START("IN2")
497   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )
498   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )
499   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
500   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
501   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
502   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
503   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_PLAYER(2)
504   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_PLAYER(2)
505
506   PORT_START("DSW1") // coinage
507   PORT_DIPNAME( 0x01, 0x01, "UNK1-01" )
508   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
509   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
510   PORT_DIPNAME( 0x02, 0x02, "UNK1-02" )
511   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
512   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
513   PORT_DIPNAME( 0x04, 0x04, "UNK1-04" )
514   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
515   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
516   PORT_DIPNAME( 0x08, 0x08, "UNK1-08" )
517   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
518   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
519   PORT_DIPNAME( 0x10, 0x10, "UNK1-10" )
520   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
521   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
522   PORT_DIPNAME( 0x20, 0x20, "UNK1-20" )
523   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
524   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
525   PORT_DIPNAME( 0x40, 0x40, "UNK1-40" )
526   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
527   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
528   PORT_DIPNAME( 0x80, 0x80, "UNK1-80" )
529   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
530   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
531
532   PORT_START("DSW2")
533   PORT_DIPNAME( 0x01, 0x01, "UNK2-01" )
534   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
535   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
536   PORT_DIPNAME( 0x02, 0x02, "UNK2-02" )
537   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
538   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
539   PORT_DIPNAME( 0x04, 0x04, "UNK2-04" )
540   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
541   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
542   PORT_DIPNAME( 0x08, 0x08, "UNK2-08 Demo Music On" )
543   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
544   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
545   PORT_DIPNAME( 0x10, 0x10, "UNK2-10" )
546   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
547   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
548   PORT_DIPNAME( 0x20, 0x20, "UNK2-20" )
549   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
550   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
551   PORT_DIPNAME( 0x40, 0x40, "UNK2-40" )
552   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
553   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
554   PORT_DIPNAME( 0x80, 0x80, "UNK2-80" )
555   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
556   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
557INPUT_PORTS_END
558
559static INPUT_PORTS_START( ufo800 )
560   PORT_START("IN1")
561   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Test Button")
562   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P1 Service Coin")
563   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_NAME("P1 Coin 1")
564   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_NAME("P1 Coin 2")
565   PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
566
567   PORT_START("IN2")
568   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )
569   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )
570   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
571   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
572   PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
573
574   PORT_START("DSW1") // coinage
575   PORT_DIPNAME( 0x01, 0x01, "UNK1-01" )
576   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
577   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
578   PORT_DIPNAME( 0x02, 0x02, "UNK1-02" )
579   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
580   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
581   PORT_DIPNAME( 0x04, 0x04, "UNK1-04" )
582   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
583   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
584   PORT_DIPNAME( 0x08, 0x08, "UNK1-08" )
585   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
586   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
587   PORT_DIPNAME( 0x10, 0x10, "UNK1-10" )
588   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
589   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
590   PORT_DIPNAME( 0x20, 0x20, "UNK1-20" )
591   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
592   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
593   PORT_DIPNAME( 0x40, 0x40, "UNK1-40" )
594   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
595   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
596   PORT_DIPNAME( 0x80, 0x80, "UNK1-80" )
597   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
598   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
599
600   PORT_START("DSW2")
601   PORT_DIPNAME( 0x01, 0x01, "UNK2-01 BGM Select" )
602   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
603   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
604   PORT_DIPNAME( 0x02, 0x02, "UNK2-02 BGM Select" )
605   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
606   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
607   PORT_DIPNAME( 0x04, 0x04, "UNK2-04" )
608   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
609   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
610   PORT_DIPNAME( 0x08, 0x08, "UNK2-08" )
611   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
612   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
613   PORT_DIPNAME( 0x10, 0x10, "UNK2-10" )
614   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
615   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
616   PORT_DIPNAME( 0x20, 0x20, "UNK2-20" )
617   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
618   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
619   PORT_DIPNAME( 0x40, 0x40, "UNK2-40" )
620   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
621   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
622   PORT_DIPNAME( 0x80, 0x80, "UNK2-80" )
623   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
624   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
625INPUT_PORTS_END
626
627
628
398629/***************************************************************************
399630
400631  Machine Config
r241573r241574
453684   // all ports set to input
454685   MCFG_315_5296_IN_PORTA_CB(READ8(ufo_state, crane_limits_r))
455686   MCFG_315_5296_IN_PORTB_CB(READ8(ufo_state, crane_limits_r))
456   MCFG_315_5296_IN_PORTE_CB(IOPORT("P1"))
687   MCFG_315_5296_IN_PORTE_CB(IOPORT("IN1"))
457688   MCFG_315_5296_IN_PORTF_CB(IOPORT("DSW1"))
458689   MCFG_315_5296_IN_PORTG_CB(IOPORT("DSW2"))
459   MCFG_315_5296_IN_PORTH_CB(IOPORT("P2"))
690   MCFG_315_5296_IN_PORTH_CB(IOPORT("IN2"))
460691
461692   MCFG_DEVICE_ADD("io2", SEGA_315_5296, 16000000)
462693   // all ports set to output
r241573r241574
491722
492723   /* basic machine hardware */
493724   MCFG_DEVICE_MODIFY("io1")
494   MCFG_315_5296_IN_PORTC_CB(IOPORT("P1"))
495   MCFG_315_5296_IN_PORTE_CB(NOOP)
496   MCFG_315_5296_IN_PORTH_CB(NOOP)
725   MCFG_315_5296_IN_PORTC_CB(IOPORT("IN1"))
726   MCFG_315_5296_IN_PORTE_CB(NULL)
727   MCFG_315_5296_IN_PORTH_CB(NULL)
497728MACHINE_CONFIG_END
498729
499730
731static MACHINE_CONFIG_DERIVED( ufo21, newufo )
500732
733   /* basic machine hardware */
734   MCFG_DEVICE_MODIFY("io1")
735   MCFG_315_5296_IN_PORTA_CB(READ8(ufo_state, ex_crane_limits_r))
736   MCFG_315_5296_IN_PORTB_CB(READ8(ufo_state, ex_crane_limits_r))
737   MCFG_315_5296_IN_PORTC_CB(READ8(ufo_state, ex_crane_open_r))
738
739   MCFG_DEVICE_MODIFY("io2")
740   MCFG_315_5296_OUT_PORTA_CB(WRITE8(ufo_state, ex_stepper_w))
741   MCFG_315_5296_OUT_PORTE_CB(WRITE8(ufo_state, ex_crane_xyz_w))
742   MCFG_315_5296_OUT_PORTF_CB(WRITE8(ufo_state, ex_crane_xyz_w))
743MACHINE_CONFIG_END
744
745static MACHINE_CONFIG_DERIVED( ufo800, ufo21 )
746
747   /* basic machine hardware */
748   MCFG_DEVICE_MODIFY("io1")
749   MCFG_315_5296_IN_PORTB_CB(IOPORT("IN2"))
750   MCFG_315_5296_IN_PORTD_CB(IOPORT("IN1"))
751   MCFG_315_5296_IN_PORTE_CB(NULL)
752   MCFG_315_5296_IN_PORTH_CB(NULL)
753
754   MCFG_DEVICE_MODIFY("io2")
755   MCFG_315_5296_OUT_PORTF_CB(NULL) // ufo lamps?
756MACHINE_CONFIG_END
757
758
759
501760/***************************************************************************
502761
503762  Game drivers
r241573r241574
550809GAMEL( 1991, newufo_nfl,   newufo, newufo,  newufo,  driver_device, 0, ROT0, "Sega", "New UFO Catcher (Team NFL)", GAME_MECHANICAL | GAME_SUPPORTS_SAVE, layout_segaufo )
551810GAMEL( 1991, newufo_xmas,  newufo, newufo,  newufo,  driver_device, 0, ROT0, "Sega", "New UFO Catcher (Christmas season ROM kit)", GAME_MECHANICAL | GAME_SUPPORTS_SAVE, layout_segaufo )
552811GAMEL( 1991, ufomini,      0,      ufomini, ufomini, driver_device, 0, ROT0, "Sega", "UFO Catcher Mini", GAME_MECHANICAL | GAME_SUPPORTS_SAVE, layout_segaufo )
553GAMEL( 1996, ufo21,        0,      newufo,  newufo,  driver_device, 0, ROT0, "Sega", "UFO Catcher 21", GAME_NOT_WORKING | GAME_MECHANICAL | GAME_SUPPORTS_SAVE, layout_segaufo )
554GAMEL( 1998, ufo800,       0,      newufo,  newufo,  driver_device, 0, ROT0, "Sega", "UFO Catcher 800", GAME_NOT_WORKING | GAME_MECHANICAL | GAME_SUPPORTS_SAVE, layout_segaufo )
812GAMEL( 1996, ufo21,        0,      ufo21,   ufo21,   driver_device, 0, ROT0, "Sega", "UFO Catcher 21", GAME_IMPERFECT_SOUND | GAME_MECHANICAL | GAME_SUPPORTS_SAVE, layout_segaufo )
813GAMEL( 1998, ufo800,       0,      ufo800,  ufo800,  driver_device, 0, ROT0, "Sega", "UFO Catcher 800", GAME_NOT_WORKING | GAME_MECHANICAL | GAME_SUPPORTS_SAVE, layout_segaufo )


Previous 199869 Revisions Next


© 1997-2024 The MAME Team