Previous 199869 Revisions Next

r19582 Sunday 16th December, 2012 at 11:19:57 UTC by Robbbert
CPS2 : added digital volume control [Barry Harris]

I have attached a patch which allows CPS-2 games to use their digital volume (up & down) buttons. The buttons are mapped to the usual MAME volume up & down buttons, and the test screen sound sliders work, as does the expected change in actual sound volume.

I have also added support for disabling the volume slider in the test menu, as used by the single board games (eg, mvscjsing). These games didn't have the digital controls (they replaced them with a volume knob), and the test screen shouldn't display the slider (confirmed by smitdogg).
[src/mame/drivers]cps2.c
[src/mame/includes]cps1.h

trunk/src/mame/includes/cps1.h
r19581r19582
22#define _CPS1_H_
33
44#include "sound/msm5205.h"
5#include "sound/qsound.h"
56
67struct gfx_range
78{
r19581r19582
124125   int          m_dial[2];      // forgottn
125126   int          m_readpaddle;   // pzloop2
126127   int          m_cps2networkpresent;
128   int          m_cps2digitalvolumelevel;
129   int          m_cps2disabledigitalvolume;
130   emu_timer    *m_digital_volume_timer;
127131
128132   /* fcrash sound hw */
129133   int          m_sample_buffer1;
r19581r19582
211215   DECLARE_DRIVER_INIT(cps2crpt);
212216   DECLARE_DRIVER_INIT(ssf2tb);
213217   DECLARE_DRIVER_INIT(pzloop2);
218   DECLARE_DRIVER_INIT(singbrd);
214219   DECLARE_DRIVER_INIT(gigaman2);
215220   TILEMAP_MAPPER_MEMBER(tilemap0_scan);
216221   TILEMAP_MAPPER_MEMBER(tilemap1_scan);
r19581r19582
232237   INTERRUPT_GEN_MEMBER(cps1_interrupt);
233238   TIMER_DEVICE_CALLBACK_MEMBER(ganbare_interrupt);
234239   TIMER_DEVICE_CALLBACK_MEMBER(cps2_interrupt);
240   TIMER_CALLBACK_MEMBER(cps2_update_digital_volume);
235241   
236242   /* fcrash handlers */
237243   DECLARE_DRIVER_INIT(kodb);
trunk/src/mame/drivers/cps2.c
r19581r19582
764764 *  Sound ?
765765 *
766766 *************************************/
767 
768 TIMER_CALLBACK_MEMBER(cps_state::cps2_update_digital_volume)
769 {
770   int vol_button_state;
767771
772   vol_button_state = ioport("DIGITALVOL")->read();
773
774   if (vol_button_state & 0x01) m_cps2digitalvolumelevel -= 1;
775   if (vol_button_state & 0x02) m_cps2digitalvolumelevel += 1;
776   
777   if (m_cps2digitalvolumelevel > 39) m_cps2digitalvolumelevel = 39;
778   if (m_cps2digitalvolumelevel < 0) m_cps2digitalvolumelevel = 0;
779   
780   machine().device<qsound_device>("qsound")->set_output_gain(0, m_cps2digitalvolumelevel / 39.0);
781   machine().device<qsound_device>("qsound")->set_output_gain(1, m_cps2digitalvolumelevel / 39.0);
782 }
783
768784static READ16_HANDLER( cps2_qsound_volume_r )
769785{
770786   cps_state *state = space.machine().driver_data<cps_state>();
771
787   
788   UINT16 cps2_vol_states[40] =
789   {
790      0xf010, 0xf008, 0xf004, 0xf002, 0xf001, 0xe810, 0xe808, 0xe804, 0xe802, 0xe801,
791      0xe410, 0xe408, 0xe404, 0xe402, 0xe401, 0xe210, 0xe208, 0xe204, 0xe202, 0xe201,
792      0xe110, 0xe108, 0xe104, 0xe102, 0xe101, 0xe090, 0xe088, 0xe084, 0xe082, 0xe081,
793      0xe050, 0xe048, 0xe044, 0xe042, 0xe041, 0xe030, 0xe028, 0xe024, 0xe022, 0xe021
794   };
795   
796   UINT16 result;
797   
798   result = cps2_vol_states[state->m_cps2digitalvolumelevel];
799   
772800   /* Extra adapter memory (0x660000-0x663fff) available when bit 14 = 0 */
773801   /* Network adapter (ssf2tb) present when bit 15 = 0 */
774802   /* Only game known to use both these so far is SSF2TB */
775803
776804   if (state->m_cps2networkpresent)
777      return 0x2021;
805      return 0x2021; /* SSF2TB doesn't have a digital slider in the test screen */
778806   else
779      return 0xe021;
807   if (state->m_cps2disabledigitalvolume)
808      return 0xd000; /* digital display isn't shown in test mode */
809   else
810      return result;
780811}
781812
782813
r19581r19582
928959   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_device, write_bit)
929960   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_device, set_clock_line)
930961   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_device, set_cs_line)
962   
963   /* fake inputs for digital volume buttons */
964   PORT_START( "DIGITALVOL" )
965   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_VOLUME_DOWN )
966   PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_VOLUME_UP )
931967INPUT_PORTS_END
932968
933969/* 4 players and 3 buttons */
r19581r19582
81628198 *
81638199 *************************************/
81648200
8201 static void init_digital_volume(running_machine &machine)
8202 {
8203   cps_state *state = machine.driver_data<cps_state>();
8204   
8205   state->m_cps2digitalvolumelevel = 39; /* maximum */
8206   state->m_cps2disabledigitalvolume = 0;
8207   
8208   /* create a timer to update our volume state from the fake switches - read it every 6 frames or so to enable some granularity */
8209   state->m_digital_volume_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(cps_state::cps2_update_digital_volume),state));
8210   state->m_digital_volume_timer->adjust(attotime::from_msec(100), 0, attotime::from_msec(100));
8211 }
8212 
81658213DRIVER_INIT_MEMBER(cps_state,cps2)
81668214{
81678215
r19581r19582
81728220   DRIVER_INIT_CALL(cps2_video);
81738221
81748222   m_cps2networkpresent = 0;
8175
8223   
8224   init_digital_volume(machine());
8225   
81768226   machine().device("maincpu")->set_clock_scale(0.7375f); /* RAM access waitstates etc. aren't emulated - slow the CPU to compensate */
81778227}
81788228
r19581r19582
82018251   machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x804000, 0x804001, FUNC(joy_or_paddle_r));
82028252}
82038253
8254DRIVER_INIT_MEMBER(cps_state,singbrd)
8255{
8256   DRIVER_INIT_CALL(cps2);
8257   
8258   /* the single board games don't have a digital volume switch */
8259   m_cps2disabledigitalvolume = 1;
8260   m_digital_volume_timer->adjust(attotime::never, 0, attotime::never);
8261}
8262
82048263static READ16_HANDLER( gigaman2_dummyqsound_r )
82058264{
82068265   cps_state *state = space.machine().driver_data<cps_state>();
r19581r19582
82468305   machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x618000, 0x619fff, FUNC(gigaman2_dummyqsound_r), FUNC(gigaman2_dummyqsound_w)); // no qsound..
82478306   space.set_decrypted_region(0x000000, (length) - 1, &rom[length/4]);
82488307   m68k_set_encrypted_opcode_range(machine().device("maincpu"), 0, length);
8308   
8309   /* no digital volume switches on this? */
8310   m_digital_volume_timer->adjust(attotime::never, 0, attotime::never);
82498311}
82508312
82518313
r19581r19582
84478509GAME( 1998, mvscur1,    mvsc,     cps2, cps2_2p6b, cps_state, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (USA 971222)", GAME_SUPPORTS_SAVE )
84488510GAME( 1998, mvscj,      mvsc,     cps2, cps2_2p6b, cps_state, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Japan 980123)", GAME_SUPPORTS_SAVE )
84498511GAME( 1998, mvscjr1,    mvsc,     cps2, cps2_2p6b, cps_state, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Japan 980112)", GAME_SUPPORTS_SAVE )
8450GAME( 1998, mvscjsing,  mvsc,     cps2, cps2_2p6b, cps_state, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Japan 980123) (Single PCB)", GAME_SUPPORTS_SAVE )
8512GAME( 1998, mvscjsing,  mvsc,     cps2, cps2_2p6b, cps_state, singbrd,  ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Japan 980123) (Single PCB)", GAME_SUPPORTS_SAVE )
84518513GAME( 1998, mvsca,      mvsc,     cps2, cps2_2p6b, cps_state, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Asia 980123)", GAME_SUPPORTS_SAVE )
84528514GAME( 1998, mvscar1,    mvsc,     cps2, cps2_2p6b, cps_state, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Asia 980112)", GAME_SUPPORTS_SAVE )
84538515GAME( 1998, mvsch,      mvsc,     cps2, cps2_2p6b, cps_state, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Hispanic 980123)", GAME_SUPPORTS_SAVE )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team