Previous 15994 Revisions Next

r14956 Tuesday 17th April, 2012 at 17:55:05 UTC by Miodrag Milanović
DIRECT_UPDATE_HANDLER change for a2600 (nw)
[src/emu]memory.h
[src/mess/drivers]a2600.c

src/emu/memory.h
r14955r14956
814814// opcode base adjustment handler function macro
815815#define DIRECT_UPDATE_MEMBER(name)      offs_t name(ATTR_UNUSED direct_read_data &direct, ATTR_UNUSED offs_t address)
816816#define DIRECT_UPDATE_HANDLER(name)      offs_t name(ATTR_UNUSED running_machine &machine, ATTR_UNUSED direct_read_data &direct, ATTR_UNUSED offs_t address)
817#define DECLARE_DIRECT_UPDATE_MEMBER(name)   offs_t name(ATTR_UNUSED direct_read_data &direct, ATTR_UNUSED offs_t address)
817818
818819
819820// space read/write handler function macros
src/mess/drivers/a2600.c
r14955r14956
6666   unsigned m_FVlocked;
6767   UINT16 m_current_screen_height;
6868   int m_FETimer;
69
70   direct_update_delegate m_FE_old_opbase_handler;
71   
72   DECLARE_DIRECT_UPDATE_MEMBER(modeF6_opbase);
73   DECLARE_DIRECT_UPDATE_MEMBER(modeSS_opbase);
74   DECLARE_DIRECT_UPDATE_MEMBER(modeDPC_opbase_handler);
75   DECLARE_DIRECT_UPDATE_MEMBER(modeFE_opbase_handler);   
6976};
7077
7178
r14955r14956
741748}
742749
743750
744DIRECT_UPDATE_HANDLER( modeF6_opbase )
751DIRECT_UPDATE_MEMBER(a2600_state::modeF6_opbase)
745752{
746753   if ( ( address & 0x1FFF ) >= 0x1FF6 && ( address & 0x1FFF ) <= 0x1FF9 )
747754   {
748      modeF6_switch_w( machine.device("maincpu")->memory().space(AS_PROGRAM), ( address & 0x1FFF ) - 0x1FF6, 0 );
755      modeF6_switch_w( machine().device("maincpu")->memory().space(AS_PROGRAM), ( address & 0x1FFF ) - 0x1FF6, 0 );
749756   }
750757   return address;
751758}
752759
753DIRECT_UPDATE_HANDLER( modeSS_opbase )
760DIRECT_UPDATE_MEMBER(a2600_state::modeSS_opbase)
754761{
755   a2600_state *state = machine.driver_data<a2600_state>();
756762   if ( address & 0x1000 )
757763   {
758764      if ( address & 0x800 )
759765      {
760         direct.explicit_configure(( address & 0xf800 ), ( address & 0xf800 ) | 0x7ff, 0x7ff, state->m_bank_base[2]);
766         direct.explicit_configure(( address & 0xf800 ), ( address & 0xf800 ) | 0x7ff, 0x7ff, m_bank_base[2]);
761767      }
762768      else
763769      {
764         direct.explicit_configure(( address & 0xf800 ), ( address & 0xf800 ) | 0x7ff, 0x7ff, state->m_bank_base[1]);
770         direct.explicit_configure(( address & 0xf800 ), ( address & 0xf800 ) | 0x7ff, 0x7ff, m_bank_base[1]);
765771      }
766772      return ~0;
767773   }
r14955r14956
936942   }
937943}
938944
939DIRECT_UPDATE_HANDLER(modeDPC_opbase_handler)
945DIRECT_UPDATE_MEMBER(a2600_state::modeDPC_opbase_handler)
940946{
941   a2600_state *state = machine.driver_data<a2600_state>();
942947   UINT8   new_bit;
943   new_bit = ( state->m_dpc.shift_reg & 0x80 ) ^ ( ( state->m_dpc.shift_reg & 0x20 ) << 2 );
944   new_bit = new_bit ^ ( ( ( state->m_dpc.shift_reg & 0x10 ) << 3 ) ^ ( ( state->m_dpc.shift_reg & 0x08 ) << 4 ) );
948   new_bit = ( m_dpc.shift_reg & 0x80 ) ^ ( ( m_dpc.shift_reg & 0x20 ) << 2 );
949   new_bit = new_bit ^ ( ( ( m_dpc.shift_reg & 0x10 ) << 3 ) ^ ( ( m_dpc.shift_reg & 0x08 ) << 4 ) );
945950   new_bit = new_bit ^ 0x80;
946   state->m_dpc.shift_reg = new_bit | ( state->m_dpc.shift_reg >> 1 );
951   m_dpc.shift_reg = new_bit | ( m_dpc.shift_reg >> 1 );
947952   return address;
948953}
949954
r14955r14956
10851090
10861091 */
10871092
1088direct_update_delegate FE_old_opbase_handler;
10891093
1090DIRECT_UPDATE_HANDLER(modeFE_opbase_handler)
1094DIRECT_UPDATE_MEMBER(a2600_state::modeFE_opbase_handler)
10911095{
1092   a2600_state *state = machine.driver_data<a2600_state>();
1093   if ( ! state->m_FETimer )
1096   if ( ! m_FETimer )
10941097   {
10951098      /* Still cheating a bit here by looking bit 13 of the address..., but the high byte of the
10961099           cpu should be the last byte that was on the data bus and so should determine the bank
10971100           we should switch in. */
1098      state->m_bank_base[1] = machine.region("user1")->base() + 0x1000 * ( ( address & 0x2000 ) ? 0 : 1 );
1099      memory_set_bankptr(machine, "bank1", state->m_bank_base[1] );
1101      m_bank_base[1] = machine().region("user1")->base() + 0x1000 * ( ( address & 0x2000 ) ? 0 : 1 );
1102      memory_set_bankptr(machine(), "bank1", m_bank_base[1] );
11001103      /* and restore old opbase handler */
1101      machine.device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(FE_old_opbase_handler);
1104      machine().device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(m_FE_old_opbase_handler);
11021105   }
11031106   else
11041107   {
11051108      /* Wait for one memory access to have passed (reading of new PCH either from code or from stack) */
1106      state->m_FETimer--;
1109      m_FETimer--;
11071110   }
11081111   return address;
11091112}
r14955r14956
11161119       should be the last byte that was on the data bus
11171120    */
11181121   state->m_FETimer = 1;
1119   FE_old_opbase_handler = space->set_direct_update_handler(direct_update_delegate(FUNC(modeFE_opbase_handler), &machine));
1122   state->m_FE_old_opbase_handler = space->set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeFE_opbase_handler), state));
11201123}
11211124
11221125static READ8_HANDLER(modeFE_switch_r)
r14955r14956
19071910   case modeF6:
19081911      space->install_legacy_write_handler(0x1ff6, 0x1ff9, FUNC(modeF6_switch_w));
19091912      space->install_legacy_read_handler(0x1ff6, 0x1ff9, FUNC(modeF6_switch_r));
1910      space->set_direct_update_handler(direct_update_delegate(FUNC(modeF6_opbase), &machine));
1913      space->set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeF6_opbase), state));
19111914      break;
19121915
19131916   case modeF4:
r14955r14956
19621965      memory_set_bankptr(machine, "bank2", state->m_bank_base[2] );
19631966      state->m_modeSS_write_enabled = 0;
19641967      state->m_modeSS_byte_started = 0;
1965      space->set_direct_update_handler(direct_update_delegate(FUNC(modeSS_opbase), &machine));
1968      space->set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeSS_opbase), state));
19661969      /* The Supercharger has no motor control so just enable it */
19671970      machine.device<cassette_image_device>(CASSETTE_TAG)->change_state(CASSETTE_MOTOR_ENABLED, CASSETTE_MOTOR_DISABLED );
19681971      break;
r14955r14956
19771980      space->install_legacy_write_handler(0x1040, 0x107f, FUNC(modeDPC_w));
19781981      space->install_legacy_write_handler(0x1ff8, 0x1ff9, FUNC(modeF8_switch_w));
19791982      space->install_legacy_read_handler(0x1ff8, 0x1ff9, FUNC(modeF8_switch_r));
1980      space->set_direct_update_handler(direct_update_delegate(FUNC(modeDPC_opbase_handler), &machine));
1983      space->set_direct_update_handler(direct_update_delegate(FUNC(a2600_state::modeDPC_opbase_handler), state));
19811984      {
19821985         int   data_fetcher;
19831986         for( data_fetcher = 0; data_fetcher < 8; data_fetcher++ )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team