From 62fd9b344d3f97e3e5e68fc833e2d9be75bc2427 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 15 Jun 2022 08:29:55 +0200 Subject: [PATCH] Cleanup using state object --- src/mame/includes/amstrad.h | 1 + src/mame/includes/bebox.h | 1 + src/mame/includes/dgn_beta.h | 4 ++-- src/mame/machine/amstrad.cpp | 14 ++++++-------- src/mame/machine/bebox.cpp | 13 ++++++------- src/mame/machine/dgn_beta.cpp | 12 ++++++------ src/mame/machine/n64.cpp | 2 -- 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/mame/includes/amstrad.h b/src/mame/includes/amstrad.h index dbbb75fe064..deda66687e8 100644 --- a/src/mame/includes/amstrad.h +++ b/src/mame/includes/amstrad.h @@ -250,6 +250,7 @@ private: uint8_t amstrad_ppi_portb_r(); void amstrad_ppi_portc_w(uint8_t data); + device_t* get_expansion_device(const char* tag); DECLARE_WRITE_LINE_MEMBER( cpc_romdis ); void rom_select(uint8_t data); diff --git a/src/mame/includes/bebox.h b/src/mame/includes/bebox.h index 59f850dba3d..ccb3282e1e3 100644 --- a/src/mame/includes/bebox.h +++ b/src/mame/includes/bebox.h @@ -105,6 +105,7 @@ private: void at_dma8237_1_w(offs_t offset, uint8_t data); uint8_t bebox_dma_read_byte(offs_t offset); void bebox_dma_write_byte(offs_t offset, uint8_t data); + inline void set_dma_channel(int channel, int state); uint64_t scsi53c810_r(offs_t offset, uint64_t mem_mask = ~0); void scsi53c810_w(offs_t offset, uint64_t data, uint64_t mem_mask = ~0); uint64_t bb_slave_64be_r(offs_t offset, uint64_t mem_mask = ~0); diff --git a/src/mame/includes/dgn_beta.h b/src/mame/includes/dgn_beta.h index 974968a5e74..5042de05259 100644 --- a/src/mame/includes/dgn_beta.h +++ b/src/mame/includes/dgn_beta.h @@ -215,8 +215,8 @@ private: void UpdateBanks(int first, int last); void SetDefaultTask(); void dgn_beta_bank_memory(int offset, int data, int bank); - int SelectedKeyrow(dgn_beta_state *state, int Rows); - int GetKeyRow(dgn_beta_state *state, int RowNo); + int SelectedKeyrow(int Rows); + int GetKeyRow(int RowNo); void cpu0_recalc_irq(int state); void cpu0_recalc_firq(int state); void cpu1_recalc_firq(int state); diff --git a/src/mame/machine/amstrad.cpp b/src/mame/machine/amstrad.cpp index 0910624225e..5e53da7cd68 100644 --- a/src/mame/machine/amstrad.cpp +++ b/src/mame/machine/amstrad.cpp @@ -1069,11 +1069,9 @@ uint32_t amstrad_state::screen_update_amstrad(screen_device &screen, bitmap_ind1 /* traverses the daisy-chain of expansion devices, looking for the specified device */ -static device_t* get_expansion_device(running_machine &machine, const char* tag) +device_t* amstrad_state::get_expansion_device(const char* tag) { - amstrad_state *state = machine.driver_data(); - cpc_expansion_slot_device* exp_port = state->m_exp; - + cpc_expansion_slot_device* exp_port = m_exp; while (exp_port != nullptr) { device_t* temp; @@ -2166,7 +2164,7 @@ The exception is the case where none of b7-b0 are reset (i.e. port &FBFF), which m_crtc->set_unscaled_clock( ( m_aleste_mode & 0x02 ) ? ( XTAL(16'000'000) / 8 ) : ( XTAL(16'000'000) / 16 ) ); } - mface2 = dynamic_cast(get_expansion_device(machine(),"multiface2")); + mface2 = dynamic_cast(get_expansion_device("multiface2")); if(mface2 != nullptr) { if(mface2->multiface_io_write(offset, data) != 0) @@ -2399,7 +2397,7 @@ void amstrad_state::amstrad_rethinkMemory() } /* multiface hardware enabled? */ - mface2 = dynamic_cast(get_expansion_device(machine(),"multiface2")); + mface2 = dynamic_cast(get_expansion_device("multiface2")); if(mface2 != nullptr) { if (mface2->multiface_hardware_enabled()) @@ -2432,7 +2430,7 @@ WRITE_LINE_MEMBER(amstrad_state::screen_vblank_amstrad) // rising edge if (state) { - cpc_multiface2_device* mface2 = dynamic_cast(get_expansion_device(machine(),"multiface2")); + cpc_multiface2_device* mface2 = dynamic_cast(get_expansion_device("multiface2")); if(mface2 != nullptr) { @@ -2975,7 +2973,7 @@ void amstrad_state::enumerate_roms() /* add ROMs from ROMbox expansion */ - device_t* romexp = get_expansion_device(machine(),"rom"); + device_t* romexp = get_expansion_device("rom"); if(romexp) { for(int i = 0; i < 8; i++) diff --git a/src/mame/machine/bebox.cpp b/src/mame/machine/bebox.cpp index dda04ddb2b0..204fc095cc9 100644 --- a/src/mame/machine/bebox.cpp +++ b/src/mame/machine/bebox.cpp @@ -551,16 +551,15 @@ WRITE_LINE_MEMBER(bebox_state::bebox_dma8237_out_eop){ m_smc37c78->tc_w(state); } -static void set_dma_channel(running_machine &machine, int channel, int state) +inline void bebox_state::set_dma_channel(int channel, int state) { - bebox_state *drvstate = machine.driver_data(); - if (!state) drvstate->m_dma_channel = channel; + if (!state) m_dma_channel = channel; } -WRITE_LINE_MEMBER(bebox_state::pc_dack0_w){ set_dma_channel(machine(), 0, state); } -WRITE_LINE_MEMBER(bebox_state::pc_dack1_w){ set_dma_channel(machine(), 1, state); } -WRITE_LINE_MEMBER(bebox_state::pc_dack2_w){ set_dma_channel(machine(), 2, state); } -WRITE_LINE_MEMBER(bebox_state::pc_dack3_w){ set_dma_channel(machine(), 3, state); } +WRITE_LINE_MEMBER(bebox_state::pc_dack0_w){ set_dma_channel(0, state); } +WRITE_LINE_MEMBER(bebox_state::pc_dack1_w){ set_dma_channel(1, state); } +WRITE_LINE_MEMBER(bebox_state::pc_dack2_w){ set_dma_channel(2, state); } +WRITE_LINE_MEMBER(bebox_state::pc_dack3_w){ set_dma_channel(3, state); } /************************************* * diff --git a/src/mame/machine/dgn_beta.cpp b/src/mame/machine/dgn_beta.cpp index 57ef3ec8fc7..564609d8c5b 100644 --- a/src/mame/machine/dgn_beta.cpp +++ b/src/mame/machine/dgn_beta.cpp @@ -260,7 +260,7 @@ than using a walking zero as the OS-9 driver does. This meant that SelectKeyrow never moved past the first row, by scanning for the last active row the beta_test rom works, and it does not break the OS-9 driver :) */ -int dgn_beta_state::SelectedKeyrow(dgn_beta_state *state, int Rows) +int dgn_beta_state::SelectedKeyrow(int Rows) { int Idx; int Row; /* Row selected */ @@ -288,7 +288,7 @@ int dgn_beta_state::SelectedKeyrow(dgn_beta_state *state, int Rows) /* GetKeyRow, returns the value of a keyrow, checking for invalid rows */ /* and returning no key pressed if row is invalid */ -int dgn_beta_state::GetKeyRow(dgn_beta_state *state, int RowNo) +int dgn_beta_state::GetKeyRow(int RowNo) { if(RowNo==INVALID_KEYROW) return NO_KEY_PRESSED; /* row is invalid, so return no key down */ @@ -336,7 +336,7 @@ uint8_t dgn_beta_state::d_pia0_pb_r() m_KAny_next = 0; - Selected = SelectedKeyrow(this, m_RowShifter); + Selected = SelectedKeyrow(m_RowShifter); /* Scan the whole keyboard, if output shifter is all low */ /* This actually scans in the keyboard */ @@ -352,7 +352,7 @@ uint8_t dgn_beta_state::d_pia0_pb_r() } else /* Just scan current row, from previously read values */ { - if(GetKeyRow(this, Selected) != NO_KEY_PRESSED) + if(GetKeyRow(Selected) != NO_KEY_PRESSED) m_KAny_next = 1; } @@ -398,8 +398,8 @@ WRITE_LINE_MEMBER(dgn_beta_state::d_pia0_cb2_w) /* load keyrow on rising edge of CB2 */ if((state==1) && (m_d_pia0_cb2_last==0)) { - RowNo=SelectedKeyrow(this, m_RowShifter); - m_Keyrow=GetKeyRow(this, RowNo); + RowNo=SelectedKeyrow(m_RowShifter); + m_Keyrow=GetKeyRow(RowNo); /* Output clock rising edge, clock CB2 value into rowshifterlow to high transition */ /* In the beta the shift registers are a cmos 4015, and a cmos 4013 in series */ diff --git a/src/mame/machine/n64.cpp b/src/mame/machine/n64.cpp index ea066f44335..7aabc803b7f 100644 --- a/src/mame/machine/n64.cpp +++ b/src/mame/machine/n64.cpp @@ -1113,8 +1113,6 @@ uint32_t n64_periphs::vi_reg_r(offs_t offset, uint32_t mem_mask) void n64_periphs::vi_reg_w(offs_t offset, uint32_t data, uint32_t mem_mask) { - //n64_state *state = machine().driver_data(); - switch (offset) { case 0x00/4: // VI_CONTROL_REG