Previous 199869 Revisions Next

r20454 Thursday 24th January, 2013 at 22:17:58 UTC by Wilbert Pol
(MESS) pentagon.c: Start cutting down on the number of tagmap lookups. (nw)
[src/mess/drivers]pentagon.c

trunk/src/mess/drivers/pentagon.c
r20453r20454
1313{
1414public:
1515   pentagon_state(const machine_config &mconfig, device_type type, const char *tag)
16      : spectrum_state(mconfig, type, tag) { }
16      : spectrum_state(mconfig, type, tag)
17      , m_maincpu(*this, "maincpu")
18   { }
1719
1820   DECLARE_DIRECT_UPDATE_MEMBER(pentagon_direct);
1921   DECLARE_WRITE8_MEMBER(pentagon_port_7ffd_w);
2022   DECLARE_MACHINE_RESET(pentagon);
23
24protected:
25   required_device<cpu_device> m_maincpu;
26   UINT8 *m_maincpu_rom;
27
28   void pentagon_update_memory();
2129};
2230
2331DIRECT_UPDATE_MEMBER(pentagon_state::pentagon_direct)
2432{
2533   device_t *beta = machine().device(BETA_DISK_TAG);
26   UINT16 pc = machine().device("maincpu")->safe_pcbase();
34   UINT16 pc = m_maincpu->pcbase();
2735
2836   if (beta->started() && betadisk_is_active(beta))
2937   {
r20453r20454
3139      {
3240         m_ROMSelection = ((m_port_7ffd_data>>4) & 0x01) ? 1 : 0;
3341         betadisk_disable(beta);
34         membank("bank1")->set_base(memregion("maincpu")->base() + 0x010000 + (m_ROMSelection<<14));
42         membank("bank1")->set_base(m_maincpu_rom + 0x010000 + (m_ROMSelection<<14));
3543      }
3644   } else if (((pc & 0xff00) == 0x3d00) && (m_ROMSelection==1))
3745   {
r20453r20454
4856            membank("bank1")->set_base(machine().root_device().memregion("beta:beta")->base());
4957         }
5058      } else {
51         direct.explicit_configure(0x0000, 0x3fff, 0x3fff, machine().root_device().memregion("maincpu")->base() + 0x010000 + (m_ROMSelection<<14));
52         membank("bank1")->set_base(machine().root_device().memregion("maincpu")->base() + 0x010000 + (m_ROMSelection<<14));
59         direct.explicit_configure(0x0000, 0x3fff, 0x3fff, m_maincpu_rom + 0x010000 + (m_ROMSelection<<14));
60         membank("bank1")->set_base(m_maincpu_rom + 0x010000 + (m_ROMSelection<<14));
5361      }
5462      return ~0;
5563   }
5664   return address;
5765}
5866
59static void pentagon_update_memory(running_machine &machine)
67void pentagon_state::pentagon_update_memory()
6068{
61   spectrum_state *state = machine.driver_data<spectrum_state>();
62   device_t *beta = machine.device(BETA_DISK_TAG);
63   UINT8 *messram = machine.device<ram_device>(RAM_TAG)->pointer();
64   state->m_screen_location = messram + ((state->m_port_7ffd_data & 8) ? (7<<14) : (5<<14));
69   device_t *beta = machine().device(BETA_DISK_TAG);
70   UINT8 *messram = machine().device<ram_device>(RAM_TAG)->pointer();
71   m_screen_location = messram + ((m_port_7ffd_data & 8) ? (7<<14) : (5<<14));
6572
66   state->membank("bank4")->set_base(messram + ((state->m_port_7ffd_data & 0x07) * 0x4000));
73   membank("bank4")->set_base(messram + ((m_port_7ffd_data & 0x07) * 0x4000));
6774
68   if (beta->started() && betadisk_is_active(beta) && !( state->m_port_7ffd_data & 0x10 ) )
75   if (beta->started() && betadisk_is_active(beta) && !( m_port_7ffd_data & 0x10 ) )
6976   {
7077      /* GLUK */
71      if (strcmp(machine.system().name, "pent1024")==0) {
72         state->m_ROMSelection = 2;
78      if (strcmp(machine().system().name, "pent1024")==0) {
79         m_ROMSelection = 2;
7380      } else {
74         state->m_ROMSelection = ((state->m_port_7ffd_data>>4) & 0x01) ;
81         m_ROMSelection = ((m_port_7ffd_data>>4) & 0x01) ;
7582      }
7683   }
7784   else {
7885      /* ROM switching */
79      state->m_ROMSelection = ((state->m_port_7ffd_data>>4) & 0x01) ;
86      m_ROMSelection = ((m_port_7ffd_data>>4) & 0x01) ;
8087   }
8188   /* rom 0 is 128K rom, rom 1 is 48 BASIC */
82   state->membank("bank1")->set_base(machine.root_device().memregion("maincpu")->base() + 0x010000 + (state->m_ROMSelection<<14));
89   membank("bank1")->set_base(m_maincpu_rom + 0x010000 + (m_ROMSelection<<14));
8390}
8491
8592WRITE8_MEMBER(pentagon_state::pentagon_port_7ffd_w)
r20453r20454
9299   m_port_7ffd_data = data;
93100
94101   /* update memory */
95   pentagon_update_memory(machine());
102   pentagon_update_memory();
96103}
97104
98105static ADDRESS_MAP_START (pentagon_io, AS_IO, 8, pentagon_state )
r20453r20454
112119{
113120   UINT8 *messram = machine().device<ram_device>(RAM_TAG)->pointer();
114121   device_t *beta = machine().device(BETA_DISK_TAG);
115   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
122   address_space &space = m_maincpu->space(AS_PROGRAM);
116123
124   m_maincpu_rom = memregion("maincpu")->base();
125
117126   space.install_read_bank(0x0000, 0x3fff, "bank1");
118127   space.unmap_write(0x0000, 0x3fff);
119128
r20453r20454
133142
134143   m_port_7ffd_data = 0;
135144   m_port_1ffd_data = -1;
136   pentagon_update_memory(machine());
145   pentagon_update_memory();
137146}
138147
139148/* F4 Character Displayer */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team