diff options
author | 2013-02-13 20:50:54 +0000 | |
---|---|---|
committer | 2013-02-13 20:50:54 +0000 | |
commit | f807712fa790b461aa59480f442dc106823c6309 (patch) | |
tree | f1dfbe99176d099c0408a1067cc0d9375c427b45 /src/mess/machine/msx_slot.c | |
parent | d96ff2ab9960eab6b9f80abda7b38a05ae654f31 (diff) |
(MESS) msx.c: Reduce tagmap lookups (nw)
Diffstat (limited to 'src/mess/machine/msx_slot.c')
-rw-r--r-- | src/mess/machine/msx_slot.c | 176 |
1 files changed, 87 insertions, 89 deletions
diff --git a/src/mess/machine/msx_slot.c b/src/mess/machine/msx_slot.c index ecfd7390cda..8bb005dfd4e 100644 --- a/src/mess/machine/msx_slot.c +++ b/src/mess/machine/msx_slot.c @@ -31,38 +31,38 @@ static void msx_cpu_setbank (running_machine &machine, int page, UINT8 *mem) { msx_state *state = machine.driver_data<msx_state>(); - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + address_space &space = state->m_maincpu->space(AS_PROGRAM); switch (page) { case 1: - state->membank ("bank1")->set_base (mem); + state->m_bank1->set_base (mem); break; case 2: - state->membank ("bank2")->set_base (mem); + state->m_bank2->set_base (mem); break; case 3: - state->membank ("bank3")->set_base (mem); + state->m_bank3->set_base (mem); break; case 4: - state->membank ("bank4")->set_base (mem); - state->membank ("bank5")->set_base (mem + 0x1ff8); + state->m_bank4->set_base (mem); + state->m_bank5->set_base (mem + 0x1ff8); space.install_read_bank(0x7ff8, 0x7fff, "bank5"); break; case 5: - state->membank ("bank6")->set_base (mem); - state->membank ("bank7")->set_base (mem + 0x1800); + state->m_bank6->set_base (mem); + state->m_bank7->set_base (mem + 0x1800); space.install_read_bank(0x9800, 0x9fff, "bank7"); break; case 6: - state->membank ("bank8")->set_base (mem); - state->membank ("bank9")->set_base (mem + 0x1800); + state->m_bank8->set_base (mem); + state->m_bank9->set_base (mem + 0x1800); space.install_read_bank(0xb800, 0xbfff, "bank9"); break; case 7: - state->membank ("bank10")->set_base (mem); + state->m_bank10->set_base (mem); break; case 8: - state->membank ("bank11")->set_base (mem); + state->m_bank11->set_base (mem); state->m_top_page = mem; break; } @@ -349,17 +349,18 @@ MSX_SLOT_RESET(konami_scc) static READ8_HANDLER (konami_scc_bank5) { + msx_state *drvstate = space.machine().driver_data<msx_state>(); if (offset & 0x80) { if ((offset & 0xff) >= 0xe0) { - return k051649_test_r (space.machine().device("k051649"), space, offset & 0xff); + return k051649_test_r(drvstate->m_k051649, space, offset & 0xff); } return 0xff; } else { - return k051649_waveform_r (space.machine().device("k051649"), space, offset & 0x7f); + return k051649_waveform_r(drvstate->m_k051649, space, offset & 0x7f); } } @@ -379,9 +380,11 @@ MSX_SLOT_MAP(konami_scc) msx_cpu_setbank (machine, 5, state->m_mem + state->m_banks[2] * 0x2000); msx_cpu_setbank (machine, 6, state->m_mem + state->m_banks[3] * 0x2000); if (state->m_cart.scc.active ) { - machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x9800, 0x9fff, FUNC(konami_scc_bank5)); + msx_state *drvstate = machine.driver_data<msx_state>(); + drvstate->m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x9800, 0x9fff, FUNC(konami_scc_bank5)); } else { - machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x9800, 0x9fff,"bank7"); + msx_state *drvstate = machine.driver_data<msx_state>(); + drvstate->m_maincpu->space(AS_PROGRAM).install_read_bank(0x9800, 0x9fff,"bank7"); } break; case 3: @@ -393,7 +396,7 @@ MSX_SLOT_MAP(konami_scc) MSX_SLOT_WRITE(konami_scc) { msx_state *drvstate = machine.driver_data<msx_state>(); - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + address_space &space = drvstate->m_maincpu->space(AS_PROGRAM); if (addr >= 0x5000 && addr < 0x5800) { state->m_banks[0] = val & state->m_bank_mask; @@ -424,32 +427,31 @@ MSX_SLOT_WRITE(konami_scc) } else if (state->m_cart.scc.active && addr >= 0x9800 && addr < 0xa000) { - device_t *k051649 = space.machine().device("k051649"); int offset = addr & 0xff; if (offset < 0x80) { - k051649_waveform_w (k051649, space, offset, val); + k051649_waveform_w (drvstate->m_k051649, space, offset, val); } else if (offset < 0xa0) { offset &= 0xf; if (offset < 0xa) { - k051649_frequency_w (k051649, space, offset, val); + k051649_frequency_w (drvstate->m_k051649, space, offset, val); } else if (offset < 0xf) { - k051649_volume_w (k051649, space, offset - 0xa, val); + k051649_volume_w (drvstate->m_k051649, space, offset - 0xa, val); } else { - k051649_keyonoff_w (k051649, space, 0, val); + k051649_keyonoff_w (drvstate->m_k051649, space, 0, val); } } else if (offset >= 0xe0) { - k051649_test_w (k051649, space, offset, val); + k051649_test_w (drvstate->m_k051649, space, offset, val); } } else if (addr >= 0xb000 && addr < 0xb800) @@ -1228,20 +1230,19 @@ MSX_SLOT_INIT(diskrom) MSX_SLOT_RESET(diskrom) { - device_t *fdc = machine.device("wd179x"); - wd17xx_reset(fdc); + msx_state *drvstate = machine.driver_data<msx_state>(); + wd17xx_reset(drvstate->m_wd179x); } static READ8_HANDLER (msx_diskrom_page1_r) { msx_state *state = space.machine().driver_data<msx_state>(); - device_t *fdc = space.machine().device("wd179x"); switch (offset) { - case 0: return wd17xx_status_r (fdc, space, 0); - case 1: return wd17xx_track_r (fdc, space, 0); - case 2: return wd17xx_sector_r (fdc, space, 0); - case 3: return wd17xx_data_r (fdc, space, 0); + case 0: return wd17xx_status_r (state->m_wd179x, space, 0); + case 1: return wd17xx_track_r (state->m_wd179x, space, 0); + case 2: return wd17xx_sector_r (state->m_wd179x, space, 0); + case 3: return wd17xx_data_r (state->m_wd179x, space, 0); case 7: return state->m_dsk_stat; default: return state->m_state[1]->m_mem[offset + 0x3ff8]; @@ -1251,19 +1252,18 @@ static READ8_HANDLER (msx_diskrom_page1_r) static READ8_HANDLER (msx_diskrom_page2_r) { msx_state *state = space.machine().driver_data<msx_state>(); - device_t *fdc = space.machine().device("wd179x"); if (offset >= 0x7f8) { switch (offset) { case 0x7f8: - return wd17xx_status_r (fdc, space, 0); + return wd17xx_status_r (state->m_wd179x, space, 0); case 0x7f9: - return wd17xx_track_r (fdc, space, 0); + return wd17xx_track_r (state->m_wd179x, space, 0); case 0x7fa: - return wd17xx_sector_r (fdc, space, 0); + return wd17xx_sector_r (state->m_wd179x, space, 0); case 0x7fb: - return wd17xx_data_r (fdc, space, 0); + return wd17xx_data_r (state->m_wd179x, space, 0); case 0x7ff: return state->m_dsk_stat; default: @@ -1279,7 +1279,7 @@ static READ8_HANDLER (msx_diskrom_page2_r) MSX_SLOT_MAP(diskrom) { msx_state *drvstate = machine.driver_data<msx_state>(); - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + address_space &space = drvstate->m_maincpu->space(AS_PROGRAM); switch (page) { case 0: @@ -1305,8 +1305,8 @@ MSX_SLOT_MAP(diskrom) MSX_SLOT_WRITE(diskrom) { - device_t *fdc = machine.device("wd179x"); - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + msx_state *drvstate = machine.driver_data<msx_state>(); + address_space &space = drvstate->m_maincpu->space(AS_PROGRAM); if (addr >= 0xa000 && addr < 0xc000) { addr -= 0x4000; @@ -1314,23 +1314,23 @@ MSX_SLOT_WRITE(diskrom) switch (addr) { case 0x7ff8: - wd17xx_command_w (fdc, space, 0, val); + wd17xx_command_w (drvstate->m_wd179x, space, 0, val); break; case 0x7ff9: - wd17xx_track_w (fdc, space, 0, val); + wd17xx_track_w (drvstate->m_wd179x, space, 0, val); break; case 0x7ffa: - wd17xx_sector_w (fdc, space, 0, val); + wd17xx_sector_w (drvstate->m_wd179x, space, 0, val); break; case 0x7ffb: - wd17xx_data_w (fdc, space, 0, val); + wd17xx_data_w (drvstate->m_wd179x, space, 0, val); break; case 0x7ffc: - wd17xx_set_side (fdc,val & 1); + wd17xx_set_side (drvstate->m_wd179x,val & 1); state->m_mem[0x3ffc] = val | 0xfe; break; case 0x7ffd: - wd17xx_set_drive (fdc,val & 1); + wd17xx_set_drive (drvstate->m_wd179x,val & 1); if ((state->m_mem[0x3ffd] ^ val) & 0x40) { set_led_status (machine, 0, !(val & 0x40)); @@ -1357,20 +1357,19 @@ MSX_SLOT_INIT(diskrom2) MSX_SLOT_RESET(diskrom2) { - device_t *fdc = machine.device("wd179x"); - wd17xx_reset (fdc); + msx_state *drvstate = machine.driver_data<msx_state>(); + wd17xx_reset (drvstate->m_wd179x); } static READ8_HANDLER (msx_diskrom2_page1_r) { msx_state *state = space.machine().driver_data<msx_state>(); - device_t *fdc = space.machine().device("wd179x"); switch (offset) { - case 0: return wd17xx_status_r(fdc, space, 0); - case 1: return wd17xx_track_r(fdc, space, 0); - case 2: return wd17xx_sector_r(fdc, space, 0); - case 3: return wd17xx_data_r(fdc, space, 0); + case 0: return wd17xx_status_r(state->m_wd179x, space, 0); + case 1: return wd17xx_track_r(state->m_wd179x, space, 0); + case 2: return wd17xx_sector_r(state->m_wd179x, space, 0); + case 3: return wd17xx_data_r(state->m_wd179x, space, 0); case 4: return state->m_dsk_stat; default: return state->m_state[1]->m_mem[offset + 0x3ff8]; @@ -1380,19 +1379,18 @@ static READ8_HANDLER (msx_diskrom2_page1_r) static READ8_HANDLER (msx_diskrom2_page2_r) { msx_state *state = space.machine().driver_data<msx_state>(); - device_t *fdc = space.machine().device("wd179x"); if (offset >= 0x7b8) { switch (offset) { case 0x7b8: - return wd17xx_status_r (fdc, space, 0); + return wd17xx_status_r (state->m_wd179x, space, 0); case 0x7b9: - return wd17xx_track_r (fdc, space, 0); + return wd17xx_track_r (state->m_wd179x, space, 0); case 0x7ba: - return wd17xx_sector_r (fdc, space, 0); + return wd17xx_sector_r (state->m_wd179x, space, 0); case 0x7bb: - return wd17xx_data_r (fdc, space, 0); + return wd17xx_data_r (state->m_wd179x, space, 0); case 0x7bc: return state->m_dsk_stat; default: @@ -1408,7 +1406,7 @@ static READ8_HANDLER (msx_diskrom2_page2_r) MSX_SLOT_MAP(diskrom2) { msx_state *drvstate = machine.driver_data<msx_state>(); - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + address_space &space = drvstate->m_maincpu->space(AS_PROGRAM); switch (page) { case 0: @@ -1433,8 +1431,8 @@ MSX_SLOT_MAP(diskrom2) MSX_SLOT_WRITE(diskrom2) { - device_t *fdc = machine.device("wd179x"); - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + msx_state *drvstate = machine.driver_data<msx_state>(); + address_space &space = drvstate->m_maincpu->space(AS_PROGRAM); if (addr >= 0xa000 && addr < 0xc000) { addr -= 0x4000; @@ -1442,21 +1440,21 @@ MSX_SLOT_WRITE(diskrom2) switch (addr) { case 0x7fb8: - wd17xx_command_w (fdc, space, 0, val); + wd17xx_command_w (drvstate->m_wd179x, space, 0, val); break; case 0x7fb9: - wd17xx_track_w (fdc, space, 0, val); + wd17xx_track_w (drvstate->m_wd179x, space, 0, val); break; case 0x7fba: - wd17xx_sector_w (fdc, space, 0, val); + wd17xx_sector_w (drvstate->m_wd179x, space, 0, val); break; case 0x7fbb: - wd17xx_data_w (fdc, space, 0, val); + wd17xx_data_w (drvstate->m_wd179x, space, 0, val); break; case 0x7fbc: - wd17xx_set_side (fdc,val & 1); + wd17xx_set_side (drvstate->m_wd179x,val & 1); state->m_mem[0x3fbc] = val | 0xfe; - wd17xx_set_drive (fdc,val & 1); + wd17xx_set_drive (drvstate->m_wd179x,val & 1); if ((state->m_mem[0x3fbc] ^ val) & 0x40) { set_led_status (machine, 0, !(val & 0x40)); @@ -1512,7 +1510,8 @@ MSX_SLOT_WRITE(synthesizer) { if (addr >= 0x4000 && addr < 0x8000 && !(addr & 0x0010)) { - machine.device<dac_device>("dac")->write_unsigned8(val); + msx_state *drvstate = machine.driver_data<msx_state>(); + drvstate->m_dac->write_unsigned8(val); } } @@ -1569,7 +1568,7 @@ MSX_SLOT_WRITE(majutsushi) msx_state *drvstate = machine.driver_data<msx_state>(); if (addr >= 0x5000 && addr < 0x6000) { - machine.device<dac_device>("dac")->write_unsigned8(val); + drvstate->m_dac->write_unsigned8(val); } else if (addr >= 0x6000 && addr < 0x8000) { @@ -1685,7 +1684,7 @@ MSX_SLOT_MAP(fmpac) MSX_SLOT_WRITE(fmpac) { msx_state *drvstate = machine.driver_data<msx_state>(); - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + address_space &space = drvstate->m_maincpu->space(AS_PROGRAM); int i, data; if (addr >= 0x4000 && addr < 0x6000 && state->m_cart.fmpac.sram_support) @@ -1705,13 +1704,13 @@ MSX_SLOT_WRITE(fmpac) case 0x7ff4: if (state->m_cart.fmpac.opll_active) { - ym2413_w (space.machine().device("ay8910"), space, 0, val); + ym2413_w (drvstate->m_ym, space, 0, val); } break; case 0x7ff5: if (state->m_cart.fmpac.opll_active) { - ym2413_w (space.machine().device("ay8910"), space, 1, val); + ym2413_w (drvstate->m_ym, space, 1, val); } break; case 0x7ff6: @@ -2198,7 +2197,7 @@ static READ8_HANDLER (soundcartridge_scc) if (reg < 0x80) { - return k051649_waveform_r (space.machine().device("k051649"), space, reg); + return k051649_waveform_r (state->m_k051649, space, reg); } else if (reg < 0xa0) { @@ -2207,11 +2206,11 @@ static READ8_HANDLER (soundcartridge_scc) else if (reg < 0xc0) { /* read wave 5 */ - return k051649_waveform_r (space.machine().device("k051649"), space, 0x80 + (reg & 0x1f)); + return k051649_waveform_r (state->m_k051649, space, 0x80 + (reg & 0x1f)); } else if (reg < 0xe0) { - return k051649_test_r (space.machine().device("k051649"), space, reg); + return k051649_test_r (state->m_k051649, space, reg); } return 0xff; @@ -2232,11 +2231,11 @@ static READ8_HANDLER (soundcartridge_sccp) if (reg < 0xa0) { - return k052539_waveform_r (space.machine().device("k051649"), space, reg); + return k052539_waveform_r (state->m_k051649, space, reg); } else if (reg >= 0xc0 && reg < 0xe0) { - return k051649_test_r (space.machine().device("k051649"), space, reg); + return k051649_test_r (state->m_k051649, space, reg); } return 0xff; @@ -2244,7 +2243,8 @@ static READ8_HANDLER (soundcartridge_sccp) MSX_SLOT_MAP(soundcartridge) { - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + msx_state *drvstate = machine.driver_data<msx_state>(); + address_space &space = drvstate->m_maincpu->space(AS_PROGRAM); switch (page) { case 0: @@ -2279,7 +2279,7 @@ MSX_SLOT_MAP(soundcartridge) MSX_SLOT_WRITE(soundcartridge) { msx_state *drvstate = machine.driver_data<msx_state>(); - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + address_space &space = drvstate->m_maincpu->space(AS_PROGRAM); int i; if (addr < 0x4000) @@ -2341,12 +2341,11 @@ MSX_SLOT_WRITE(soundcartridge) } else if (addr >= 0x9800 && state->m_cart.sccp.scc_active) { - device_t *k051649 = space.machine().device("k051649"); int offset = addr & 0xff; if (offset < 0x80) { - k051649_waveform_w (k051649, space, offset, val); + k051649_waveform_w (drvstate->m_k051649, space, offset, val); } else if (offset < 0xa0) { @@ -2354,20 +2353,20 @@ MSX_SLOT_WRITE(soundcartridge) if (offset < 0xa) { - k051649_frequency_w (k051649, space, offset, val); + k051649_frequency_w (drvstate->m_k051649, space, offset, val); } else if (offset < 0x0f) { - k051649_volume_w (k051649, space, offset - 0xa, val); + k051649_volume_w (drvstate->m_k051649, space, offset - 0xa, val); } else if (offset == 0x0f) { - k051649_keyonoff_w (k051649, space, 0, val); + k051649_keyonoff_w (drvstate->m_k051649, space, 0, val); } } else if (offset < 0xe0) { - k051649_test_w (k051649, space, offset, val); + k051649_test_w (drvstate->m_k051649, space, offset, val); } } } @@ -2391,12 +2390,11 @@ MSX_SLOT_WRITE(soundcartridge) } else if (addr >= 0xb800 && state->m_cart.sccp.sccp_active) { - device_t *k051649 = space.machine().device("k051649"); int offset = addr & 0xff; if (offset < 0xa0) { - k052539_waveform_w (k051649, space, offset, val); + k052539_waveform_w (drvstate->m_k051649, space, offset, val); } else if (offset < 0xc0) { @@ -2404,20 +2402,20 @@ MSX_SLOT_WRITE(soundcartridge) if (offset < 0x0a) { - k051649_frequency_w (k051649, space, offset, val); + k051649_frequency_w (drvstate->m_k051649, space, offset, val); } else if (offset < 0x0f) { - k051649_volume_w (k051649, space, offset - 0x0a, val); + k051649_volume_w (drvstate->m_k051649, space, offset - 0x0a, val); } else if (offset == 0x0f) { - k051649_keyonoff_w (k051649, space, 0, val); + k051649_keyonoff_w (drvstate->m_k051649, space, 0, val); } } else if (offset < 0xe0) { - k051649_test_w (k051649, space, offset, val); + k051649_test_w (drvstate->m_k051649, space, offset, val); } } } |