Previous 199869 Revisions Next

r21141 Saturday 16th February, 2013 at 19:04:47 UTC by Wilbert Pol
ssv.c: Reduce tagmap lookups.
[src/mame/drivers]ssv.c
[src/mame/includes]ssv.h

trunk/src/mame/drivers/ssv.c
r21140r21141
162162#include "emu.h"
163163#include "cpu/v810/v810.h"
164164#include "cpu/v60/v60.h"
165#include "machine/eeprom.h"
166165#include "machine/nvram.h"
167166#include "sound/es5506.h"
168167#include "includes/ssv.h"
r21140r21141
178177/* Update the IRQ state based on all possible causes */
179178void ssv_state::update_irq_state()
180179{
181   machine().device("maincpu")->execute().set_input_line(0, (m_requested_int & m_irq_enable)? ASSERT_LINE : CLEAR_LINE);
180   m_maincpu->set_input_line(0, (m_requested_int & m_irq_enable)? ASSERT_LINE : CLEAR_LINE);
182181}
183182
184183IRQ_CALLBACK_MEMBER(ssv_state::ssv_irq_callback)
r21140r21141
317316void ssv_state::machine_reset()
318317{
319318   m_requested_int = 0;
320   machine().device("maincpu")->execute().set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(ssv_state::ssv_irq_callback),this));
319   m_maincpu->set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(ssv_state::ssv_irq_callback),this));
321320   membank("bank1")->set_base(memregion("user1")->base());
322321}
323322
r21140r21141
444443
445444READ16_MEMBER(ssv_state::gdfs_eeprom_r)
446445{
447   device_t *device = machine().device("eeprom");
448   static const char *const gunnames[] = { "GUNX1", "GUNY1", "GUNX2", "GUNY2" };
446   ioport_port *gun[] = { m_io_gunx1, m_io_guny1, m_io_gunx2, m_io_guny2 };
449447
450   eeprom_device *eeprom = downcast<eeprom_device *>(device);
451   return (((m_gdfs_lightgun_select & 1) ? 0 : 0xff) ^ ioport(gunnames[m_gdfs_lightgun_select])->read()) | (eeprom->read_bit() << 8);
448   return (((m_gdfs_lightgun_select & 1) ? 0 : 0xff) ^ gun[m_gdfs_lightgun_select]->read()) | (m_eeprom->read_bit() << 8);
452449}
453450
454451WRITE16_MEMBER(ssv_state::gdfs_eeprom_w)
455452{
456   device_t *device = machine().device("eeprom");
457
458453   if (data & ~0x7b00)
459454      logerror("%s - Unknown EEPROM bit written %04X\n",machine().describe_context(),data);
460455
r21140r21141
464459//      data & 0x0001 ?
465460
466461      // latch the bit
467      eeprom_device *eeprom = downcast<eeprom_device *>(device);
468      eeprom->write_bit(data & 0x4000);
462      m_eeprom->write_bit(data & 0x4000);
469463
470464      // reset line asserted: reset.
471      eeprom->set_cs_line((data & 0x1000) ? CLEAR_LINE : ASSERT_LINE );
465      m_eeprom->set_cs_line((data & 0x1000) ? CLEAR_LINE : ASSERT_LINE );
472466
473467      // clock line asserted: write latch or select next bit to read
474      eeprom->set_clock_line((data & 0x2000) ? ASSERT_LINE : CLEAR_LINE );
468      m_eeprom->set_clock_line((data & 0x2000) ? ASSERT_LINE : CLEAR_LINE );
475469
476470      if (!(m_gdfs_eeprom_old & 0x0800) && (data & 0x0800))   // rising clock
477471         m_gdfs_lightgun_select = (data & 0x0300) >> 8;
r21140r21141
511505{
512506   UINT16 input_sel = *m_input_sel;
513507
514   if (input_sel & 0x0001) return ioport("KEY0")->read();
515   if (input_sel & 0x0002) return ioport("KEY1")->read();
516   if (input_sel & 0x0004) return ioport("KEY2")->read();
517   if (input_sel & 0x0008) return ioport("KEY3")->read();
508   if (input_sel & 0x0001) return m_io_key0->read();
509   if (input_sel & 0x0002) return m_io_key1->read();
510   if (input_sel & 0x0004) return m_io_key2->read();
511   if (input_sel & 0x0008) return m_io_key3->read();
518512   logerror("CPU #0 PC %06X: unknown input read: %04X\n",space.device().safe_pc(),input_sel);
519513   return 0xffff;
520514}
r21140r21141
634628{
635629   UINT16 input_sel = *m_input_sel;
636630
637   if (input_sel & 0x0002) return ioport("KEY0")->read();
638   if (input_sel & 0x0004) return ioport("KEY1")->read();
639   if (input_sel & 0x0008) return ioport("KEY2")->read();
640   if (input_sel & 0x0010) return ioport("KEY3")->read();
631   if (input_sel & 0x0002) return m_io_key0->read();
632   if (input_sel & 0x0004) return m_io_key1->read();
633   if (input_sel & 0x0008) return m_io_key2->read();
634   if (input_sel & 0x0010) return m_io_key3->read();
641635   logerror("CPU #0 PC %06X: unknown input read: %04X\n",space.device().safe_pc(),input_sel);
642636   return 0xffff;
643637}
r21140r21141
669663{
670664   if (ACCESSING_BITS_0_7)
671665   {
672      device_t *device = machine().device("ensoniq");
673666      int bank = 0x400000/2 * (data & 1); // UINT16 address
674667      int voice;
675668      for (voice = 0; voice < 32; voice++)
676         es5506_voice_bank_w(device, voice, bank);
669         es5506_voice_bank_w(m_ensoniq, voice, bank);
677670   }
678671//  popmessage("%04X",data);
679672}
r21140r21141
682675{
683676   UINT16 input_sel = *m_input_sel;
684677
685   if (input_sel & 0x0002) return ioport("KEY0")->read();
686   if (input_sel & 0x0004) return ioport("KEY1")->read();
687   if (input_sel & 0x0008) return ioport("KEY2")->read();
688   if (input_sel & 0x0010) return ioport("KEY3")->read();
678   if (input_sel & 0x0002) return m_io_key0->read();
679   if (input_sel & 0x0004) return m_io_key1->read();
680   if (input_sel & 0x0008) return m_io_key2->read();
681   if (input_sel & 0x0010) return m_io_key3->read();
689682   logerror("CPU #0 PC %06X: unknown input read: %04X\n",space.device().safe_pc(),input_sel);
690683   return 0xffff;
691684}
r21140r21141
728721
729722READ16_MEMBER(ssv_state::sxyreact_ballswitch_r)
730723{
731   return ioport("SERVICE")->read_safe(0);
724   if ( m_io_service )
725   {
726      return m_io_service->read();
727   }
728   return 0;
732729}
733730
734731READ16_MEMBER(ssv_state::sxyreact_dial_r)
r21140r21141
742739   if (ACCESSING_BITS_0_7)
743740   {
744741      if (data & 0x20)
745         m_sxyreact_serial = ioport("PADDLE")->read_safe(0) & 0xff;
742         m_sxyreact_serial = ( m_io_paddle ? m_io_paddle->read() : 0 ) & 0xff;
746743
747744      if ( (m_sxyreact_dial & 0x40) && !(data & 0x40) )   // $40 -> $00
748745         m_sxyreact_serial <<= 1;                        // shift 1 bit
r21140r21141
857854
858855READ16_MEMBER(ssv_state::eaglshot_gfxrom_r)
859856{
860   UINT8 *rom  =   memregion("gfx1")->base();
861   size_t size =   memregion("gfx1")->bytes();
857   UINT8 *rom  =   m_region_gfx1->base();
858   size_t size =   m_region_gfx1->bytes();
862859
863860   offset = offset * 2 + m_gfxrom_select * 0x200000;
864861
r21140r21141
880877{
881878   switch(m_trackball_select)
882879   {
883      case 0x60:  return (ioport("TRACKX")->read() >> 8) & 0xff;
884      case 0x40:  return (ioport("TRACKX")->read() >> 0) & 0xff;
880      case 0x60:  return (m_io_trackx->read() >> 8) & 0xff;
881      case 0x40:  return (m_io_trackx->read() >> 0) & 0xff;
885882
886      case 0x70:  return (ioport("TRACKY")->read() >> 8) & 0xff;
887      case 0x50:  return (ioport("TRACKY")->read() >> 0) & 0xff;
883      case 0x70:  return (m_io_tracky->read() >> 8) & 0xff;
884      case 0x50:  return (m_io_tracky->read() >> 0) & 0xff;
888885   }
889886   return 0;
890887}
trunk/src/mame/includes/ssv.h
r21140r21141
11#include "cpu/upd7725/upd7725.h"
22#include "video/st0020.h"
3#include "machine/eeprom.h"
34
5
46class ssv_state : public driver_device
57{
68public:
79   ssv_state(const machine_config &mconfig, device_type type, const char *tag)
810      : driver_device(mconfig, type, tag),
11      m_maincpu(*this, "maincpu"),
12      m_ensoniq(*this, "ensoniq"),
13      m_eeprom(*this, "eeprom"),
914      m_dsp(*this, "dsp"),
1015      m_mainram(*this, "mainram"),
1116      m_spriteram(*this, "spriteram"),
r21140r21141
1520      m_gdfs_tmapram(*this, "gdfs_tmapram"),
1621      m_gdfs_tmapscroll(*this, "gdfs_tmapscroll"),
1722      m_gdfs_st0020(*this, "st0020_spr"),
18      m_input_sel(*this, "input_sel"){ }
23      m_input_sel(*this, "input_sel"),
24      m_region_gfx1(*this, "gfx1"),
25      m_io_gunx1(*this, "GUNX1"),
26      m_io_guny1(*this, "GUNY1"),
27      m_io_gunx2(*this, "GUNX2"),
28      m_io_guny2(*this, "GUNY2"),
29      m_io_key0(*this, "KEY0"),
30      m_io_key1(*this, "KEY1"),
31      m_io_key2(*this, "KEY2"),
32      m_io_key3(*this, "KEY3"),
33      m_io_service(*this, "SERVICE"),
34      m_io_paddle(*this, "PADDLE"),
35      m_io_trackx(*this, "TRACKX"),
36      m_io_tracky(*this, "TRACKY")
37   { }
1938
39   required_device<cpu_device> m_maincpu;
40   required_device<device_t> m_ensoniq;
41   optional_device<eeprom_device> m_eeprom;
2042   optional_device<upd96050_device> m_dsp;
2143
2244   required_shared_ptr<UINT16> m_mainram;
r21140r21141
139161   void init_ssv(int interrupt_ultrax);
140162   void init_hypreac2_common();
141163   void init_st010();
164
165protected:
166   required_memory_region m_region_gfx1;
167   optional_ioport m_io_gunx1;
168   optional_ioport m_io_guny1;
169   optional_ioport m_io_gunx2;
170   optional_ioport m_io_guny2;
171   optional_ioport m_io_key0;
172   optional_ioport m_io_key1;
173   optional_ioport m_io_key2;
174   optional_ioport m_io_key3;
175   optional_ioport m_io_service;
176   optional_ioport m_io_paddle;
177   optional_ioport m_io_trackx;
178   optional_ioport m_io_tracky;
142179};
143
144/*----------- defined in video/ssv.c -----------*/
145void ssv_enable_video(running_machine &machine, int enable);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team