Previous 199869 Revisions Next

r20725 Monday 4th February, 2013 at 11:20:56 UTC by Robbbert
cps modernisation part 2
[src/mame/drivers]cps2.c
[src/mame/includes]cps1.h

trunk/src/mame/drivers/cps2.c
r20724r20725
688688   "0111"  /* erase command */
689689};
690690
691static WRITE16_HANDLER( cps2_eeprom_port_w )
691WRITE16_MEMBER( cps_state::cps2_eeprom_port_w )
692692{
693   cps_state *state = space.machine().driver_data<cps_state>();
694
695693   if (ACCESSING_BITS_8_15)
696694   {
697695      /* bit 0 - Unused */
r20724r20725
704702      /* bit 7 - */
705703
706704      /* EEPROM */
707      state->ioport("EEPROMOUT")->write(data, 0xffff);
705      ioport("EEPROMOUT")->write(data, 0xffff);
708706   }
709707
710708   if (ACCESSING_BITS_0_7)
r20724r20725
719717      /* bit 7 - */
720718
721719         /* Z80 Reset */
722      if (state->m_audiocpu != NULL)
723         state->m_audiocpu->set_input_line(INPUT_LINE_RESET, (data & 0x0008) ? CLEAR_LINE : ASSERT_LINE);
720      if (m_audiocpu != NULL)
721         m_audiocpu->set_input_line(INPUT_LINE_RESET, (data & 0x0008) ? CLEAR_LINE : ASSERT_LINE);
724722
725      coin_counter_w(space.machine(), 0, data & 0x0001);
726      if ((strncmp(space.machine().system().name, "pzloop2", 8) == 0) ||
727         (strncmp(space.machine().system().name, "pzloop2j", 8) == 0) ||
728         (strncmp(space.machine().system().name, "pzloop2jr1", 8) == 0))
723      coin_counter_w(machine(), 0, data & 0x0001);
724      if ((strncmp(machine().system().name, "pzloop2", 8) == 0) ||
725         (strncmp(machine().system().name, "pzloop2j", 8) == 0) ||
726         (strncmp(machine().system().name, "pzloop2jr1", 8) == 0))
729727      {
730728         // Puzz Loop 2 uses coin counter 2 input to switch between stick and paddle controls
731         state->m_readpaddle = data & 0x0002;
729         m_readpaddle = data & 0x0002;
732730      }
733731      else
734732      {
735         coin_counter_w(space.machine(), 1, data & 0x0002);
733         coin_counter_w(machine(), 1, data & 0x0002);
736734      }
737735
738      if (strncmp(space.machine().system().name, "mmatrix", 7) == 0)      // Mars Matrix seems to require the coin lockout bit to be reversed
736      if (strncmp(machine().system().name, "mmatrix", 7) == 0)      // Mars Matrix seems to require the coin lockout bit to be reversed
739737      {
740         coin_lockout_w(space.machine(), 0, data & 0x0010);
741         coin_lockout_w(space.machine(), 1, data & 0x0020);
742         coin_lockout_w(space.machine(), 2, data & 0x0040);
743         coin_lockout_w(space.machine(), 3, data & 0x0080);
738         coin_lockout_w(machine(), 0, data & 0x0010);
739         coin_lockout_w(machine(), 1, data & 0x0020);
740         coin_lockout_w(machine(), 2, data & 0x0040);
741         coin_lockout_w(machine(), 3, data & 0x0080);
744742      }
745743      else
746744      {
747         coin_lockout_w(space.machine(), 0, ~data & 0x0010);
748         coin_lockout_w(space.machine(), 1, ~data & 0x0020);
749         coin_lockout_w(space.machine(), 2, ~data & 0x0040);
750         coin_lockout_w(space.machine(), 3, ~data & 0x0080);
745         coin_lockout_w(machine(), 0, ~data & 0x0010);
746         coin_lockout_w(machine(), 1, ~data & 0x0020);
747         coin_lockout_w(machine(), 2, ~data & 0x0040);
748         coin_lockout_w(machine(), 3, ~data & 0x0080);
751749      }
752750
753751      /*
754      set_led_status(space.machine(), 0, data & 0x01);
755      set_led_status(space.machine(), 1, data & 0x10);
756      set_led_status(space.machine(), 2, data & 0x20);
752      set_led_status(machine(), 0, data & 0x01);
753      set_led_status(machine(), 1, data & 0x10);
754      set_led_status(machine(), 2, data & 0x20);
757755      */
758756   }
759757}
r20724r20725
765763 *
766764 *************************************/
767765
768   TIMER_CALLBACK_MEMBER(cps_state::cps2_update_digital_volume)
769   {
766TIMER_CALLBACK_MEMBER(cps_state::cps2_update_digital_volume)
767{
770768   int vol_button_state;
771769
772770   vol_button_state = ioport("DIGITALVOL")->read();
r20724r20725
779777
780778   machine().device<qsound_device>("qsound")->set_output_gain(0, m_cps2digitalvolumelevel / 39.0);
781779   machine().device<qsound_device>("qsound")->set_output_gain(1, m_cps2digitalvolumelevel / 39.0);
782   }
780}
783781
784static READ16_HANDLER( cps2_qsound_volume_r )
782READ16_MEMBER( cps_state::cps2_qsound_volume_r )
785783{
786   cps_state *state = space.machine().driver_data<cps_state>();
787
788   UINT16 cps2_vol_states[40] =
784   static const UINT16 cps2_vol_states[40] =
789785   {
790786      0xf010, 0xf008, 0xf004, 0xf002, 0xf001, 0xe810, 0xe808, 0xe804, 0xe802, 0xe801,
791787      0xe410, 0xe408, 0xe404, 0xe402, 0xe401, 0xe210, 0xe208, 0xe204, 0xe202, 0xe201,
r20724r20725
795791
796792   UINT16 result;
797793
798   result = cps2_vol_states[state->m_cps2digitalvolumelevel];
794   result = cps2_vol_states[m_cps2digitalvolumelevel];
799795
800796   /* Extra adapter memory (0x660000-0x663fff) available when bit 14 = 0 */
801797   /* Network adapter (ssf2tb) present when bit 15 = 0 */
802798   /* Only game known to use both these so far is SSF2TB */
803799
804   if (state->m_cps2networkpresent)
800   if (m_cps2networkpresent)
805801      return 0x2021; /* SSF2TB doesn't have a digital slider in the test screen */
806802   else
807   if (state->m_cps2disabledigitalvolume)
803   if (m_cps2disabledigitalvolume)
808804      return 0xd000; /* digital display isn't shown in test mode */
809805   else
810806      return result;
r20724r20725
817813 *
818814 *************************************/
819815
820static READ16_HANDLER( kludge_r )
816READ16_MEMBER( cps_state::kludge_r )
821817{
822818   return 0xffff;
823819}
824820
825static READ16_HANDLER( joy_or_paddle_r )
821READ16_MEMBER( cps_state::joy_or_paddle_r )
826822{
827   cps_state *state = space.machine().driver_data<cps_state>();
828
829   if (state->m_readpaddle != 0)
830      return (state->ioport("IN0")->read());
823   if (m_readpaddle != 0)
824      return (ioport("IN0")->read());
831825   else
832      return (state->ioport("PADDLE1")->read() & 0xff) | (state->ioport("PADDLE2")->read() << 8);
826      return (ioport("PADDLE1")->read() & 0xff) | (ioport("PADDLE2")->read() << 8);
833827}
834828
835829
r20724r20725
855849   AM_RANGE(0x804000, 0x804001) AM_READ_PORT("IN0")                                                            /* IN0 */
856850   AM_RANGE(0x804010, 0x804011) AM_READ_PORT("IN1")                                                            /* IN1 */
857851   AM_RANGE(0x804020, 0x804021) AM_READ_PORT("IN2")                                                            /* IN2 + EEPROM */
858   AM_RANGE(0x804030, 0x804031) AM_READ_LEGACY(cps2_qsound_volume_r)                                               /* Master volume. Also when bit 14=0 addon memory is present, when bit 15=0 network adapter present. */
859   AM_RANGE(0x804040, 0x804041) AM_WRITE_LEGACY(cps2_eeprom_port_w)                                                    /* EEPROM */
852   AM_RANGE(0x804030, 0x804031) AM_READ(cps2_qsound_volume_r)                                               /* Master volume. Also when bit 14=0 addon memory is present, when bit 15=0 network adapter present. */
853   AM_RANGE(0x804040, 0x804041) AM_WRITE(cps2_eeprom_port_w)                                                    /* EEPROM */
860854   AM_RANGE(0x8040a0, 0x8040a1) AM_WRITENOP                                                                    /* Unknown (reset once on startup) */
861   AM_RANGE(0x8040b0, 0x8040b3) AM_READ_LEGACY(kludge_r)                                                               /* unknown (xmcotaj hangs if this is 0) */
855   AM_RANGE(0x8040b0, 0x8040b3) AM_READ(kludge_r)                                                               /* unknown (xmcotaj hangs if this is 0) */
862856   AM_RANGE(0x8040e0, 0x8040e1) AM_WRITE(cps2_objram_bank_w)                                                   /* bit 0 = Object ram bank swap */
863857   AM_RANGE(0x804100, 0x80413f) AM_WRITE(cps1_cps_a_w) AM_SHARE("cps_a_regs")                          /* CPS-A custom */
864858   AM_RANGE(0x804140, 0x80417f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w)                                       /* CPS-B custom */
r20724r20725
883877   AM_RANGE(0x804000, 0x804001) AM_READ_PORT("IN0")                                                            /* IN0 */
884878   AM_RANGE(0x804010, 0x804011) AM_READ_PORT("IN1")                                                            /* IN1 */
885879   AM_RANGE(0x804020, 0x804021) AM_READ_PORT("IN2")                                                            /* IN2 + EEPROM */
886   AM_RANGE(0x804030, 0x804031) AM_READ_LEGACY(cps2_qsound_volume_r)                                               /* Master volume. Also when bit 14=0 addon memory is present, when bit 15=0 network adapter present. */
887   AM_RANGE(0x804040, 0x804041) AM_WRITE_LEGACY(cps2_eeprom_port_w)                                                    /* EEPROM */
880   AM_RANGE(0x804030, 0x804031) AM_READ(cps2_qsound_volume_r)                                               /* Master volume. Also when bit 14=0 addon memory is present, when bit 15=0 network adapter present. */
881   AM_RANGE(0x804040, 0x804041) AM_WRITE(cps2_eeprom_port_w)                                                    /* EEPROM */
888882   AM_RANGE(0x8040a0, 0x8040a1) AM_WRITENOP                                                                    /* Unknown (reset once on startup) */
889   AM_RANGE(0x8040b0, 0x8040b3) AM_READ_LEGACY(kludge_r)                                                               /* unknown (xmcotaj hangs if this is 0) */
883   AM_RANGE(0x8040b0, 0x8040b3) AM_READ(kludge_r)                                                               /* unknown (xmcotaj hangs if this is 0) */
890884   AM_RANGE(0x8040e0, 0x8040e1) AM_WRITE(cps2_objram_bank_w)                                                   /* bit 0 = Object ram bank swap */
891885   AM_RANGE(0x804100, 0x80413f) AM_WRITE(cps1_cps_a_w) AM_SHARE("cps_a_regs")                              /* CPS-A custom */
892886   AM_RANGE(0x804140, 0x80417f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w)                                       /* CPS-B custom */
r20724r20725
82718265 *
82728266 *************************************/
82738267
8274   static void init_digital_volume(running_machine &machine)
8275   {
8276   cps_state *state = machine.driver_data<cps_state>();
8268void cps_state::init_digital_volume()
8269{
8270   m_cps2digitalvolumelevel = 39; /* maximum */
8271   m_cps2disabledigitalvolume = 0;
82778272
8278   state->m_cps2digitalvolumelevel = 39; /* maximum */
8279   state->m_cps2disabledigitalvolume = 0;
8280
82818273   /* create a timer to update our volume state from the fake switches - read it every 6 frames or so to enable some granularity */
8282   state->m_digital_volume_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(cps_state::cps2_update_digital_volume),state));
8283   state->m_digital_volume_timer->adjust(attotime::from_msec(100), 0, attotime::from_msec(100));
8284   }
8274   m_digital_volume_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cps_state::cps2_update_digital_volume),this));
8275   m_digital_volume_timer->adjust(attotime::from_msec(100), 0, attotime::from_msec(100));
8276}
82858277
82868278DRIVER_INIT_MEMBER(cps_state,cps2)
82878279{
r20724r20725
82938285
82948286   m_cps2networkpresent = 0;
82958287
8296   init_digital_volume(machine());
8288   init_digital_volume();
82978289
82988290   machine().device("maincpu")->set_clock_scale(0.7375f); /* RAM access waitstates etc. aren't emulated - slow the CPU to compensate */
82998291}
r20724r20725
83188310
83198311   save_item(NAME(m_readpaddle));
83208312
8321   machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x804000, 0x804001, FUNC(joy_or_paddle_r));
8313   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x804000, 0x804001, read16_delegate(FUNC(cps_state::joy_or_paddle_r), this));
83228314}
83238315
83248316DRIVER_INIT_MEMBER(cps_state,singbrd)
r20724r20725
83308322   m_digital_volume_timer->adjust(attotime::never, 0, attotime::never);
83318323}
83328324
8333static READ16_HANDLER( gigaman2_dummyqsound_r )
8325READ16_MEMBER( cps_state::gigaman2_dummyqsound_r )
83348326{
8335   cps_state *state = space.machine().driver_data<cps_state>();
8336   return state->m_gigaman2_dummyqsound_ram[offset];
8327   return m_gigaman2_dummyqsound_ram[offset];
83378328};
83388329
8339static WRITE16_HANDLER( gigaman2_dummyqsound_w )
8330WRITE16_MEMBER( cps_state::gigaman2_dummyqsound_w )
83408331{
8341   cps_state *state = space.machine().driver_data<cps_state>();
8342   state->m_gigaman2_dummyqsound_ram[offset] = data;
8332   m_gigaman2_dummyqsound_ram[offset] = data;
83438333};
83448334
83458335/* rearrange the graphics data into the normal order */
8346static void gigaman2_gfx_reorder(running_machine &machine)
8336void cps_state::gigaman2_gfx_reorder()
83478337{
83488338   int i;
8349   int length = machine.root_device().memregion( "gfx" )->bytes();
8350   UINT16 *rom = (UINT16 *)machine.root_device().memregion("gfx")->base();
8351   UINT16 *buf = auto_alloc_array(machine, UINT16, length );
8339   int length = memregion( "gfx" )->bytes();
8340   UINT16 *rom = (UINT16 *)memregion("gfx")->base();
8341   UINT16 *buf = auto_alloc_array(machine(), UINT16, length );
83528342
83538343   memcpy (buf, rom, length);
83548344
r20724r20725
83568346      rom[i] = buf[((i & ~7) >> 2) | ((i & 4) << 18) | ((i & 2) >> 1) | ((i & 1) << 21)];
83578347   }
83588348
8359   auto_free( machine, buf );
8349   auto_free( machine(), buf );
83608350}
83618351
83628352DRIVER_INIT_MEMBER(cps_state,gigaman2)
r20724r20725
83658355   UINT16 *rom = (UINT16 *)memregion("maincpu")->base();
83668356   int length = memregion("maincpu")->bytes();
83678357
8368   gigaman2_gfx_reorder(machine());
8358   gigaman2_gfx_reorder();
83698359
83708360   DRIVER_INIT_CALL(cps2);
83718361
83728362   m_gigaman2_dummyqsound_ram = auto_alloc_array(machine(), UINT16, 0x20000 / 2);
83738363   save_pointer(NAME(m_gigaman2_dummyqsound_ram), 0x20000 / 2);
83748364
8375   machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x618000, 0x619fff, FUNC(gigaman2_dummyqsound_r), FUNC(gigaman2_dummyqsound_w)); // no qsound..
8365   space.install_readwrite_handler(0x618000, 0x619fff, read16_delegate(FUNC(cps_state::gigaman2_dummyqsound_r),this), write16_delegate(FUNC(cps_state::gigaman2_dummyqsound_w), this)); // no qsound..
83768366   space.set_decrypted_region(0x000000, (length) - 1, &rom[length/4]);
83778367   m68k_set_encrypted_opcode_range(machine().device("maincpu"), 0, length);
83788368
trunk/src/mame/includes/cps1.h
r20724r20725
257257   DECLARE_WRITE16_MEMBER(sf2mdt_layer_w);
258258   DECLARE_WRITE16_MEMBER(sf2mdta_layer_w);
259259   UINT32 screen_update_fcrash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
260
261
262   /* cps video */
260263   void cps1_get_video_base();
261264   void cps1_gfx_decode();
262265   void unshuffle(UINT64 *buf, int len);
r20724r20725
276279   UINT16 *cps2_objbase();
277280
278281
282   /* cps2 driver */
283   void init_digital_volume();
284   DECLARE_READ16_MEMBER(gigaman2_dummyqsound_r);
285   DECLARE_WRITE16_MEMBER(gigaman2_dummyqsound_w);
286   void gigaman2_gfx_reorder();
287   DECLARE_WRITE16_MEMBER(cps2_eeprom_port_w);
288   DECLARE_READ16_MEMBER(cps2_qsound_volume_r);
289   DECLARE_READ16_MEMBER(kludge_r);
290   DECLARE_READ16_MEMBER(joy_or_paddle_r);
291
279292};
280293
281294/*----------- defined in drivers/cps1.c -----------*/

Previous 199869 Revisions Next


© 1997-2024 The MAME Team