diff options
author | 2015-05-28 17:07:47 -0500 | |
---|---|---|
committer | 2015-05-28 17:07:47 -0500 | |
commit | ea2762e799e00a09155cd0d1d4a81162a8a1ab03 (patch) | |
tree | 5ecb3cfb04e49341e161c0a5db67ce5446b9febf /src/emu | |
parent | 4332164659ec242c69d3d314a523917955fb9d1c (diff) | |
parent | 8f4d8bf37ee85ff47e4628f9a365abd6d83f9436 (diff) |
Merge branch 'master' of https://github.com/mamedev/mame
Diffstat (limited to 'src/emu')
68 files changed, 566 insertions, 290 deletions
diff --git a/src/emu/bus/megadrive/svp.c b/src/emu/bus/megadrive/svp.c index 51921dbe5ac..324c5302a33 100644 --- a/src/emu/bus/megadrive/svp.c +++ b/src/emu/bus/megadrive/svp.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Fabio Priuli,Pierpaolo Prazzoli,Grazvydas Ignotas /****************************************** SVP related *****************************************/ diff --git a/src/emu/bus/megadrive/svp.h b/src/emu/bus/megadrive/svp.h index dbacd98b1ba..0f128240a86 100644 --- a/src/emu/bus/megadrive/svp.h +++ b/src/emu/bus/megadrive/svp.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Fabio Priuli,Pierpaolo Prazzoli,Grazvydas Ignotas #ifndef __MD_SVP_H #define __MD_SVP_H diff --git a/src/emu/cpu/mips/mips3.c b/src/emu/cpu/mips/mips3.c index 1b196f0fa4d..3b377dfa64f 100644 --- a/src/emu/cpu/mips/mips3.c +++ b/src/emu/cpu/mips/mips3.c @@ -1010,8 +1010,7 @@ inline bool mips3_device::RBYTE(offs_t address, UINT32 *result) { continue; } - UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start; - *result = fastbase[tlbaddress ^ m_byte_xor]; + *result = m_fastram[ramnum].offset_base8[tlbaddress ^ m_byte_xor]; return true; } *result = (*m_memory.read_byte)(*m_program, tlbaddress); @@ -1044,8 +1043,7 @@ inline bool mips3_device::RHALF(offs_t address, UINT32 *result) { continue; } - UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start; - *result = ((UINT16*)fastbase)[(tlbaddress ^ m_word_xor) >> 1]; + *result = m_fastram[ramnum].offset_base16[(tlbaddress ^ m_word_xor) >> 1]; return true; } *result = (*m_memory.read_word)(*m_program, tlbaddress); @@ -1078,8 +1076,7 @@ inline bool mips3_device::RWORD(offs_t address, UINT32 *result) { continue; } - UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start; - *result = ((UINT32*)fastbase)[tlbaddress >> 2]; + *result = m_fastram[ramnum].offset_base32[tlbaddress >> 2]; return true; } *result = (*m_memory.read_dword)(*m_program, tlbaddress); @@ -1181,8 +1178,7 @@ inline void mips3_device::WBYTE(offs_t address, UINT8 data) { continue; } - UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start; - fastbase[tlbaddress ^ m_byte_xor] = data; + m_fastram[ramnum].offset_base8[tlbaddress ^ m_byte_xor] = data; return; } (*m_memory.write_byte)(*m_program, tlbaddress, data); @@ -1216,8 +1212,7 @@ inline void mips3_device::WHALF(offs_t address, UINT16 data) { continue; } - void *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start; - ((UINT16*)fastbase)[(tlbaddress ^ m_word_xor) >> 1] = data; + m_fastram[ramnum].offset_base16[(tlbaddress ^ m_word_xor) >> 1] = data; return; } (*m_memory.write_word)(*m_program, tlbaddress, data); @@ -1251,8 +1246,7 @@ inline void mips3_device::WWORD(offs_t address, UINT32 data) { continue; } - void *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start; - ((UINT32*)fastbase)[tlbaddress >> 2] = data; + m_fastram[ramnum].offset_base32[tlbaddress >> 2] = data; return; } (*m_memory.write_dword)(*m_program, tlbaddress, data); diff --git a/src/emu/cpu/mips/mips3.h b/src/emu/cpu/mips/mips3.h index f0b860619ff..2cbdf93c28f 100644 --- a/src/emu/cpu/mips/mips3.h +++ b/src/emu/cpu/mips/mips3.h @@ -416,6 +416,9 @@ private: offs_t end; /* end of the RAM block */ UINT8 readonly; /* TRUE if read-only */ void * base; /* base in memory where the RAM lives */ + UINT8 * offset_base8; /* base in memory where the RAM lives, 8-bit pointer, with the start offset pre-applied */ + UINT16 * offset_base16; /* base in memory where the RAM lives, 16-bit pointer, with the start offset pre-applied */ + UINT32 * offset_base32; /* base in memory where the RAM lives, 32-bit pointer, with the start offset pre-applied */ } m_fastram[MIPS3_MAX_FASTRAM]; UINT64 m_debugger_temp; diff --git a/src/emu/cpu/mips/mips3drc.c b/src/emu/cpu/mips/mips3drc.c index 3e73d96f206..70c31df2220 100644 --- a/src/emu/cpu/mips/mips3drc.c +++ b/src/emu/cpu/mips/mips3drc.c @@ -182,6 +182,9 @@ void mips3_device::add_fastram(offs_t start, offs_t end, UINT8 readonly, void *b m_fastram[m_fastram_select].end = end; m_fastram[m_fastram_select].readonly = readonly; m_fastram[m_fastram_select].base = base; + m_fastram[m_fastram_select].offset_base8 = (UINT8*)base - start; + m_fastram[m_fastram_select].offset_base16 = (UINT16*)((UINT8*)base - start); + m_fastram[m_fastram_select].offset_base32 = (UINT32*)((UINT8*)base - start); m_fastram_select++; } } diff --git a/src/emu/cpu/ssp1601/ssp1601.c b/src/emu/cpu/ssp1601/ssp1601.c index e9a5f39ac1c..94720fd7e73 100644 --- a/src/emu/cpu/ssp1601/ssp1601.c +++ b/src/emu/cpu/ssp1601/ssp1601.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Pierpaolo Prazzoli,Grazvydas Ignotas /* * Samsung SSP1601 DSP emulator diff --git a/src/emu/imagedev/harddriv.c b/src/emu/imagedev/harddriv.c index bc39d53e4b3..3134506e61b 100644 --- a/src/emu/imagedev/harddriv.c +++ b/src/emu/imagedev/harddriv.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Nathan Woods, Raphael Nabet, Miodrag Milanovic /********************************************************************* diff --git a/src/emu/imagedev/harddriv.h b/src/emu/imagedev/harddriv.h index f72dc0553f1..c80044478b2 100644 --- a/src/emu/imagedev/harddriv.h +++ b/src/emu/imagedev/harddriv.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Nathan Woods, Raphael Nabet, Miodrag Milanovic /********************************************************************* diff --git a/src/emu/machine/at29040a.c b/src/emu/machine/at29040a.c index 3285b265792..31be262b7c1 100644 --- a/src/emu/machine/at29040a.c +++ b/src/emu/machine/at29040a.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Raphael Nabet, Michael Zapf /* Atmel at29c040a flash EEPROM diff --git a/src/emu/machine/at29040a.h b/src/emu/machine/at29040a.h index 1af258fb719..0dc6473edff 100644 --- a/src/emu/machine/at29040a.h +++ b/src/emu/machine/at29040a.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Raphael Nabet, Michael Zapf /* ATMEL 29040a diff --git a/src/emu/machine/rtc65271.c b/src/emu/machine/rtc65271.c index 074b8d87f48..0e5b8802754 100644 --- a/src/emu/machine/rtc65271.c +++ b/src/emu/machine/rtc65271.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Raphael Nabet, R. Belmont /* rtc65271 emulation diff --git a/src/emu/machine/rtc65271.h b/src/emu/machine/rtc65271.h index b81e92755d5..326ccf7d116 100644 --- a/src/emu/machine/rtc65271.h +++ b/src/emu/machine/rtc65271.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Raphael Nabet, R. Belmont /* rtc65271.h: include file for rtc65271.c diff --git a/src/emu/machine/smc92x4.c b/src/emu/machine/smc92x4.c index 9154648b00d..6a87f8b4bf6 100644 --- a/src/emu/machine/smc92x4.c +++ b/src/emu/machine/smc92x4.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Raphael Nabet, Michael Zapf /* HDC9224 and HDC9234 Hard and Floppy Disk Controller diff --git a/src/emu/machine/smc92x4.h b/src/emu/machine/smc92x4.h index d8b4720c87a..9cc80b815ea 100644 --- a/src/emu/machine/smc92x4.h +++ b/src/emu/machine/smc92x4.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Raphael Nabet, Michael Zapf /* Interface */ diff --git a/src/emu/machine/spchrom.c b/src/emu/machine/spchrom.c index a49590e9e00..ae906840f43 100644 --- a/src/emu/machine/spchrom.c +++ b/src/emu/machine/spchrom.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf /* spchroms.c - This is an emulator for "typical" speech ROMs from TI, as used by TI99/4(a). diff --git a/src/emu/machine/spchrom.h b/src/emu/machine/spchrom.h index 520c7fc967b..e45ba8092e5 100644 --- a/src/emu/machine/spchrom.h +++ b/src/emu/machine/spchrom.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf /* * Voice Synthesis Memory diff --git a/src/emu/machine/strata.c b/src/emu/machine/strata.c index 01651eb90bd..26da2fb3f72 100644 --- a/src/emu/machine/strata.c +++ b/src/emu/machine/strata.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Raphael Nabet, Michael Zapf /* Intel 28F640J5 Flash ROM emulation (could also handle 28F320J5 with minor diff --git a/src/emu/machine/strata.h b/src/emu/machine/strata.h index c037a24396b..f68a30e5fef 100644 --- a/src/emu/machine/strata.h +++ b/src/emu/machine/strata.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Raphael Nabet, Michael Zapf /* strata.h: header file for strata.c diff --git a/src/emu/machine/wd_fdc.c b/src/emu/machine/wd_fdc.c index 73d4a540980..687469e384b 100644 --- a/src/emu/machine/wd_fdc.c +++ b/src/emu/machine/wd_fdc.c @@ -233,7 +233,7 @@ void wd_fdc_t::seek_start(int state) { if (TRACE_COMMAND) logerror("%s: seek %d (track=%d)\n", tag(), data, track); main_state = state; - status = (status & ~(S_CRC|S_RNF|S_SPIN)) | S_BUSY; + status &= ~(S_CRC|S_RNF|S_SPIN); if(head_control) { // TODO get value from HLT callback if(command & 8) @@ -420,7 +420,7 @@ void wd_fdc_t::read_sector_start() } main_state = READ_SECTOR; - status = (status & ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM)) | S_BUSY; + status &= ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM); drop_drq(); if(side_control && floppy) floppy->ss_w((command & 0x02) ? 1 : 0); @@ -521,7 +521,7 @@ void wd_fdc_t::read_track_start() } main_state = READ_TRACK; - status = (status & ~(S_LOST|S_RNF)) | S_BUSY; + status &= ~(S_LOST|S_RNF); drop_drq(); if(side_control && floppy) floppy->ss_w((command & 0x02) ? 1 : 0); @@ -599,7 +599,7 @@ void wd_fdc_t::read_id_start() } main_state = READ_ID; - status = (status & ~(S_WP|S_DDM|S_LOST|S_RNF)) | S_BUSY; + status &= ~(S_WP|S_DDM|S_LOST|S_RNF); drop_drq(); if(side_control && floppy) floppy->ss_w((command & 0x02) ? 1 : 0); @@ -675,7 +675,7 @@ void wd_fdc_t::write_track_start() } main_state = WRITE_TRACK; - status = (status & ~(S_WP|S_DDM|S_LOST|S_RNF)) | S_BUSY; + status &= ~(S_WP|S_DDM|S_LOST|S_RNF); drop_drq(); if(side_control && floppy) floppy->ss_w((command & 0x02) ? 1 : 0); @@ -785,7 +785,7 @@ void wd_fdc_t::write_sector_start() } main_state = WRITE_SECTOR; - status = (status & ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM)) | S_BUSY; + status &= ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM); drop_drq(); if(side_control && floppy) floppy->ss_w((command & 0x02) ? 1 : 0); @@ -1041,7 +1041,17 @@ void wd_fdc_t::cmd_w(UINT8 val) cmd_buffer = val; - delay_cycles(t_cmd, dden ? delay_command_commit*2 : delay_command_commit); + if ((val & 0xf0) == 0xd0) + { + // force interrupt is executed instantly (?) + delay_cycles(t_cmd, 0); + } + else + { + // set busy, then set a timer to process the command + status |= S_BUSY; + delay_cycles(t_cmd, dden ? delay_command_commit*2 : delay_command_commit); + } } UINT8 wd_fdc_t::status_r() @@ -1649,6 +1659,10 @@ void wd_fdc_t::live_run(attotime limit) cur_live.shift_reg == 0xf56b ? 0x9fc6 : cur_live.shift_reg == 0xf56e ? 0xafa5 : 0xbf84; + + if((cur_live.data_reg & 0xfe) == 0xf8) + status |= S_DDM; + cur_live.data_separator_phase = false; cur_live.bit_counter = 0; cur_live.state = READ_SECTOR_DATA; diff --git a/src/emu/netlist/analog/nld_ms_direct.h b/src/emu/netlist/analog/nld_ms_direct.h index 08894933000..b5021e1c9f6 100644 --- a/src/emu/netlist/analog/nld_ms_direct.h +++ b/src/emu/netlist/analog/nld_ms_direct.h @@ -10,7 +10,7 @@ #include "nld_solver.h" -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> class netlist_matrix_solver_direct_t: public netlist_matrix_solver_t { public: @@ -23,7 +23,7 @@ public: /* ATTR_COLD */ virtual void vsetup(netlist_analog_net_t::list_t &nets); /* ATTR_COLD */ virtual void reset() { netlist_matrix_solver_t::reset(); } - ATTR_HOT inline int N() const { return (m_N == 0 ? m_dim : m_N); } + ATTR_HOT inline unsigned N() const { if (m_N == 0) return m_dim; else return m_N; } ATTR_HOT inline int vsolve_non_dynamic(const bool newton_raphson); @@ -56,7 +56,7 @@ protected: private: - const int m_dim; + const unsigned m_dim; nl_double m_lp_fact; }; @@ -64,10 +64,10 @@ private: // netlist_matrix_solver_direct // ---------------------------------------------------------------------------------------- -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t() { - for (int k = 0; k < N(); k++) + for (unsigned k = 0; k < N(); k++) { pfree(m_terms[k]); } @@ -75,7 +75,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t pfree_array(m_rails_temp); } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep() { nl_double new_solver_timestep = m_params.m_max_timestep; @@ -86,7 +86,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next * FIXME: We should extend the logic to use either all nets or * only output nets. */ - for (int k = 0; k < N(); k++) + for (unsigned k = 0; k < N(); k++) { netlist_analog_net_t *n = m_nets[k]; @@ -114,7 +114,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next return new_solver_timestep; } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k, netlist_terminal_t *term) { if (term->m_otherterm->net().isRailNet()) @@ -139,13 +139,13 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k, } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_analog_net_t::list_t &nets) { if (m_dim < nets.size()) netlist().error("Dimension %d less than %" SIZETFMT, m_dim, nets.size()); - for (int k = 0; k < N(); k++) + for (unsigned k = 0; k < N(); k++) { m_terms[k]->clear(); m_rails_temp[k].clear(); @@ -153,10 +153,10 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a netlist_matrix_solver_t::setup(nets); - for (int k = 0; k < N(); k++) + for (unsigned k = 0; k < N(); k++) { m_terms[k]->m_railstart = m_terms[k]->count(); - for (int i = 0; i < m_rails_temp[k].count(); i++) + for (unsigned i = 0; i < m_rails_temp[k].count(); i++) this->m_terms[k]->add(m_rails_temp[k].terms()[i], m_rails_temp[k].net_other()[i]); m_rails_temp[k].clear(); // no longer needed @@ -187,8 +187,8 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a int sort_order = (type() == GAUSS_SEIDEL ? 1 : -1); - for (int k = 0; k < N() / 2; k++) - for (int i = 0; i < N() - 1; i++) + for (unsigned k = 0; k < N() / 2; k++) + for (unsigned i = 0; i < N() - 1; i++) { if ((m_terms[i]->m_railstart - m_terms[i+1]->m_railstart) * sort_order < 0) { @@ -197,10 +197,10 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a } } - for (int k = 0; k < N(); k++) + for (unsigned k = 0; k < N(); k++) { int *other = m_terms[k]->net_other(); - for (int i = 0; i < m_terms[k]->count(); i++) + for (unsigned i = 0; i < m_terms[k]->count(); i++) if (other[i] != -1) other[i] = get_net_idx(&m_terms[k]->terms()[i]->m_otherterm->net()); } @@ -209,35 +209,35 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_A() { - for (int k = 0; k < N(); k++) + for (unsigned k = 0; k < N(); k++) { - for (int i=0; i < N(); i++) + for (unsigned i=0; i < N(); i++) m_A[k][i] = 0.0; nl_double akk = 0.0; - const int terms_count = m_terms[k]->count(); - const int railstart = m_terms[k]->m_railstart; + const unsigned terms_count = m_terms[k]->count(); + const unsigned railstart = m_terms[k]->m_railstart; const nl_double * RESTRICT gt = m_terms[k]->gt(); const nl_double * RESTRICT go = m_terms[k]->go(); const int * RESTRICT net_other = m_terms[k]->net_other(); - for (int i = 0; i < terms_count; i++) + for (unsigned i = 0; i < terms_count; i++) akk = akk + gt[i]; m_A[k][k] += akk; - for (int i = 0; i < railstart; i++) + for (unsigned i = 0; i < railstart; i++) m_A[k][net_other[i]] += -go[i]; } } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_RHS() { - for (int k = 0; k < N(); k++) + for (unsigned k = 0; k < N(); k++) { nl_double rhsk_a = 0.0; nl_double rhsk_b = 0.0; @@ -258,7 +258,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_RHS() } } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve() { #if 0 @@ -271,15 +271,15 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve() printf("\n"); #endif - const int kN = N(); + const unsigned kN = N(); - for (int i = 0; i < kN; i++) { + for (unsigned i = 0; i < kN; i++) { // FIXME: use a parameter to enable pivoting? if (USE_PIVOT_SEARCH) { /* Find the row with the largest first value */ - int maxrow = i; - for (int j = i + 1; j < kN; j++) + unsigned maxrow = i; + for (unsigned j = i + 1; j < kN; j++) { if (nl_math::abs(m_A[j][i]) > nl_math::abs(m_A[maxrow][i])) maxrow = j; @@ -288,7 +288,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve() if (maxrow != i) { /* Swap the maxrow and ith row */ - for (int k = i; k < kN; k++) { + for (unsigned k = i; k < kN; k++) { std::swap(m_A[i][k], m_A[maxrow][k]); } std::swap(m_RHS[i], m_RHS[maxrow]); @@ -300,12 +300,12 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve() /* Eliminate column i from row j */ - for (int j = i + 1; j < kN; j++) + for (unsigned j = i + 1; j < kN; j++) { const nl_double f1 = - m_A[j][i] * f; if (f1 != NL_FCONST(0.0)) { - for (int k = i + 1; k < kN; k++) + for (unsigned k = i + 1; k < kN; k++) m_A[j][k] += m_A[i][k] * f1; m_RHS[j] += m_RHS[i] * f1; } @@ -313,18 +313,18 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve() } } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_back_subst( nl_double * RESTRICT x) { - const int kN = N(); + const unsigned kN = N(); /* back substitution */ for (int j = kN - 1; j >= 0; j--) { nl_double tmp = 0; - for (int k = j + 1; k < kN; k++) + for (unsigned k = j + 1; k < kN; k++) tmp += m_A[j][k] * x[k]; x[j] = (m_RHS[j] - tmp) / m_A[j][j]; @@ -342,13 +342,13 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_back_subst( } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta( const nl_double * RESTRICT V) { nl_double cerr = 0; nl_double cerr2 = 0; - for (int i = 0; i < this->N(); i++) + for (unsigned i = 0; i < this->N(); i++) { const nl_double e = nl_math::abs(V[i] - this->m_nets[i]->m_cur_Analog); const nl_double e2 = nl_math::abs(m_RHS[i] - this->m_last_RHS[i]); @@ -359,24 +359,24 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta( return cerr + cerr2*NL_FCONST(100000.0); } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::store( const nl_double * RESTRICT V, const bool store_RHS) { - for (int i = 0; i < this->N(); i++) + for (unsigned i = 0; i < this->N(); i++) { this->m_nets[i]->m_cur_Analog = V[i]; } if (store_RHS) { - for (int i = 0; i < this->N(); i++) + for (unsigned i = 0; i < this->N(); i++) { this->m_last_RHS[i] = m_RHS[i]; } } } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve() { solve_base<netlist_matrix_solver_direct_t>(this); @@ -384,7 +384,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve() } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic(ATTR_UNUSED const bool newton_raphson) { nl_double new_v[_storage_N]; // = { 0.0 }; @@ -406,7 +406,7 @@ ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic( } } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT inline int netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson) { this->build_LE_A(); @@ -416,7 +416,7 @@ ATTR_HOT inline int netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_ return this->solve_non_dynamic(newton_raphson); } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(const netlist_solver_parameters_t ¶ms, const int size) : netlist_matrix_solver_t(GAUSSIAN_ELIMINATION, params) , m_dim(size) @@ -425,7 +425,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t( m_terms = palloc_array(terms_t *, N()); m_rails_temp = palloc_array(terms_t, N()); - for (int k = 0; k < N(); k++) + for (unsigned k = 0; k < N(); k++) { m_terms[k] = palloc(terms_t); m_last_RHS[k] = 0.0; @@ -433,7 +433,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t( } } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(const eSolverType type, const netlist_solver_parameters_t ¶ms, const int size) : netlist_matrix_solver_t(type, params) , m_dim(size) @@ -442,7 +442,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t( m_terms = palloc_array(terms_t *, N()); m_rails_temp = palloc_array(terms_t, N()); - for (int k = 0; k < N(); k++) + for (unsigned k = 0; k < N(); k++) { m_terms[k] = palloc(terms_t); m_last_RHS[k] = 0.0; diff --git a/src/emu/netlist/analog/nld_ms_sor.h b/src/emu/netlist/analog/nld_ms_sor.h index 11ee4273d62..25799dbb1e6 100644 --- a/src/emu/netlist/analog/nld_ms_sor.h +++ b/src/emu/netlist/analog/nld_ms_sor.h @@ -15,7 +15,7 @@ #include "nld_solver.h" #include "nld_ms_direct.h" -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> class netlist_matrix_solver_SOR_t: public netlist_matrix_solver_direct_t<m_N, _storage_N> { public: @@ -46,7 +46,7 @@ private: // netlist_matrix_solver - Gauss - Seidel // ---------------------------------------------------------------------------------------- -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> void netlist_matrix_solver_SOR_t<m_N, _storage_N>::log_stats() { if (this->m_stat_calculations != 0 && this->m_params.m_log_stats) @@ -66,14 +66,14 @@ void netlist_matrix_solver_SOR_t<m_N, _storage_N>::log_stats() } } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT nl_double netlist_matrix_solver_SOR_t<m_N, _storage_N>::vsolve() { this->solve_base(this); return this->compute_next_timestep(); } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT inline int netlist_matrix_solver_SOR_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson) { const int iN = this->N(); diff --git a/src/emu/netlist/analog/nld_ms_sor_mat.h b/src/emu/netlist/analog/nld_ms_sor_mat.h index 184df6313ff..9c5a29382f1 100644 --- a/src/emu/netlist/analog/nld_ms_sor_mat.h +++ b/src/emu/netlist/analog/nld_ms_sor_mat.h @@ -15,7 +15,7 @@ #include "nld_solver.h" #include "nld_ms_direct.h" -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> class netlist_matrix_solver_SOR_mat_t: public netlist_matrix_solver_direct_t<m_N, _storage_N> { public: @@ -57,7 +57,7 @@ private: // netlist_matrix_solver - Gauss - Seidel // ---------------------------------------------------------------------------------------- -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::log_stats() { if (this->m_stat_calculations != 0 && m_log_stats) @@ -77,7 +77,7 @@ void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::log_stats() } } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve() { /* @@ -85,13 +85,13 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve() */ if (USE_LINEAR_PREDICTION) - for (int k = 0; k < this->N(); k++) + for (unsigned k = 0; k < this->N(); k++) { this->m_last_V[k] = this->m_nets[k]->m_cur_Analog; this->m_nets[k]->m_cur_Analog = this->m_nets[k]->m_cur_Analog + this->m_Vdelta[k] * this->current_timestep() * m_lp_fact; } else - for (int k = 0; k < this->N(); k++) + for (unsigned k = 0; k < this->N(); k++) { this->m_last_V[k] = this->m_nets[k]->m_cur_Analog; } @@ -103,7 +103,7 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve() nl_double sq = 0; nl_double sqo = 0; const nl_double rez_cts = 1.0 / this->current_timestep(); - for (int k = 0; k < this->N(); k++) + for (unsigned k = 0; k < this->N(); k++) { const netlist_analog_net_t *n = this->m_nets[k]; const nl_double nv = (n->m_cur_Analog - this->m_last_V[k]) * rez_cts ; @@ -123,7 +123,7 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve() return this->compute_next_timestep(); } -template <int m_N, int _storage_N> +template <unsigned m_N, unsigned _storage_N> ATTR_HOT inline int netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson) { /* The matrix based code looks a lot nicer but actually is 30% slower than diff --git a/src/emu/netlist/analog/nld_solver.c b/src/emu/netlist/analog/nld_solver.c index 703f6f35770..ebabf6e33d7 100644 --- a/src/emu/netlist/analog/nld_solver.c +++ b/src/emu/netlist/analog/nld_solver.c @@ -51,7 +51,7 @@ ATTR_COLD void terms_t::add(netlist_terminal_t *term, int net_other) ATTR_COLD void terms_t::set_pointers() { - for (int i = 0; i < count(); i++) + for (unsigned i = 0; i < count(); i++) { m_term[i]->m_gt1 = &m_gt[i]; m_term[i]->m_go1 = &m_go[i]; @@ -156,7 +156,7 @@ ATTR_COLD void netlist_matrix_solver_t::setup(netlist_analog_net_t::list_t &nets break; } } - NL_VERBOSE_OUT(("added net with %d populated connections\n", net->m_core_terms.size())); + //NL_VERBOSE_OUT(("added net with %" SIZETFMT " populated connections\n", net->m_core_terms.size())); } } diff --git a/src/emu/netlist/analog/nld_solver.h b/src/emu/netlist/analog/nld_solver.h index 874c8dc7e1d..7ab2f4a7733 100644 --- a/src/emu/netlist/analog/nld_solver.h +++ b/src/emu/netlist/analog/nld_solver.h @@ -65,7 +65,7 @@ class terms_t ATTR_COLD void add(netlist_terminal_t *term, int net_other); - ATTR_HOT inline int count() { return m_term.size(); } + ATTR_HOT inline unsigned count() { return m_term.size(); } ATTR_HOT inline netlist_terminal_t **terms() { return m_term.data(); } ATTR_HOT inline int *net_other() { return m_net_other.data(); } @@ -76,7 +76,7 @@ class terms_t ATTR_COLD void set_pointers(); - int m_railstart; + unsigned m_railstart; private: plist_t<netlist_terminal_t *> m_term; diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c index f17b638c6e1..f239beb1069 100644 --- a/src/emu/netlist/devices/net_lib.c +++ b/src/emu/netlist/devices/net_lib.c @@ -41,7 +41,7 @@ NETLIST_END() #define ENTRY1(_nic, _name, _defparam) factory.register_device<_nic>( # _name, xstr(_nic), _defparam ); #define ENTRY(_nic, _name, _defparam) ENTRY1(NETLIB_NAME(_nic), _name, _defparam) -void nl_initialize_factory(netlist_factory_t &factory) +void nl_initialize_factory(netlist_factory_list_t &factory) { ENTRY(R, RES, "R") ENTRY(POT, POT, "R") diff --git a/src/emu/netlist/devices/net_lib.h b/src/emu/netlist/devices/net_lib.h index c6ab75fe522..1ae4336f62e 100644 --- a/src/emu/netlist/devices/net_lib.h +++ b/src/emu/netlist/devices/net_lib.h @@ -67,6 +67,6 @@ NETLIST_EXTERNAL(diode_models); NETLIST_EXTERNAL(bjt_models); -void nl_initialize_factory(netlist_factory_t &factory); +void nl_initialize_factory(netlist_factory_list_t &factory); #endif diff --git a/src/emu/netlist/devices/nld_system.c b/src/emu/netlist/devices/nld_system.c index f97a0e14147..b7a5cf6c71e 100644 --- a/src/emu/netlist/devices/nld_system.c +++ b/src/emu/netlist/devices/nld_system.c @@ -76,7 +76,7 @@ NETLIB_START(extclock) connect(m_feedback, m_Q); { netlist_time base = netlist_time::from_hz(m_freq.Value()*2); - nl_util::pstring_list pat = nl_util::split(m_pattern.Value(),","); + pstring_list_t pat(m_pattern.Value(),","); m_off = netlist_time::from_double(m_offset.Value()); int pati[256]; diff --git a/src/emu/netlist/devices/nld_truthtable.c b/src/emu/netlist/devices/nld_truthtable.c index 85fc56ac34b..03acc31d4f4 100644 --- a/src/emu/netlist/devices/nld_truthtable.c +++ b/src/emu/netlist/devices/nld_truthtable.c @@ -6,7 +6,7 @@ */ #include "nld_truthtable.h" -#include "../plists.h" +#include "../plib/plists.h" unsigned truthtable_desc_t::count_bits(UINT32 v) { @@ -97,7 +97,7 @@ UINT32 truthtable_desc_t::get_ignored_extended(UINT32 i) // desc // ---------------------------------------------------------------------------------------- -ATTR_COLD void truthtable_desc_t::help(unsigned cur, nl_util::pstring_list list, +ATTR_COLD void truthtable_desc_t::help(unsigned cur, pstring_list_t list, UINT64 state,UINT16 val, UINT8 *timing_index) { pstring elem = list[cur].trim(); @@ -142,15 +142,17 @@ ATTR_COLD void truthtable_desc_t::help(unsigned cur, nl_util::pstring_list list, } } -ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled_ignore) +ATTR_COLD void truthtable_desc_t::setup(const pstring_list_t &truthtable, UINT32 disabled_ignore) { + unsigned line = 0; + if (*m_initialized) return; - pstring ttline = pstring(truthtable[0]); - truthtable++; - ttline = pstring(truthtable[0]); - truthtable++; + pstring ttline = truthtable[line]; + line++; + ttline = truthtable[line]; + line++; for (unsigned j=0; j < m_size; j++) m_outs[j] = ~0L; @@ -160,14 +162,14 @@ ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled while (!ttline.equals("")) { - nl_util::pstring_list io = nl_util::split(ttline,"|"); + pstring_list_t io(ttline,"|"); // checks nl_assert_always(io.size() == 3, "io.count mismatch"); - nl_util::pstring_list inout = nl_util::split(io[0], ","); + pstring_list_t inout(io[0], ","); nl_assert_always(inout.size() == m_num_bits, "number of bits not matching"); - nl_util::pstring_list out = nl_util::split(io[1], ","); + pstring_list_t out(io[1], ","); nl_assert_always(out.size() == m_NO, "output count not matching"); - nl_util::pstring_list times = nl_util::split(io[2], ","); + pstring_list_t times(io[2], ","); nl_assert_always(times.size() == m_NO, "timing count not matching"); UINT16 val = 0; @@ -189,8 +191,8 @@ ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled } help(0, inout, 0 , val, tindex.data()); - ttline = pstring(truthtable[0]); - truthtable++; + ttline = truthtable[line]; + line++; } // determine ignore @@ -233,3 +235,35 @@ ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled *m_initialized = true; } + +#define ENTRYX(_n,_m,_h) case (_n * 1000 + _m * 10 + _h): \ + { typedef netlist_factory_truthtable_t<_n,_m,_h> xtype; \ + return palloc(xtype,name,classname,def_param); } break + +#define ENTRYY(_n,_m) ENTRYX(_n,_m,0); ENTRYX(_n,_m,1) + +#define ENTRY(_n) ENTRYY(_n, 1); ENTRYY(_n, 2); ENTRYY(_n, 3); ENTRYY(_n, 4); ENTRYY(_n, 5); ENTRYY(_n, 6) + +netlist_base_factory_truthtable_t *nl_tt_factory_create(const unsigned ni, const unsigned no, + const unsigned has_state, + const pstring &name, const pstring &classname, + const pstring &def_param) +{ + switch (ni * 1000 + no * 10 + has_state) + { + ENTRY(1); + ENTRY(2); + ENTRY(3); + ENTRY(4); + ENTRY(5); + ENTRY(6); + ENTRY(7); + ENTRY(8); + ENTRY(9); + ENTRY(10); + default: + pstring msg = pstring::sprintf("unable to create truthtable<%d,%d,%d>", ni, no, has_state); + nl_assert_always(false, msg.cstr()); + } + return NULL; +} diff --git a/src/emu/netlist/devices/nld_truthtable.h b/src/emu/netlist/devices/nld_truthtable.h index d12dd3c578b..3f447d28f2e 100644 --- a/src/emu/netlist/devices/nld_truthtable.h +++ b/src/emu/netlist/devices/nld_truthtable.h @@ -11,6 +11,7 @@ #define NLD_TRUTHTABLE_H_ #include "../nl_base.h" +#include "../nl_factory.h" #define NETLIB_TRUTHTABLE(_name, _nIN, _nOUT, _state) \ class NETLIB_NAME(_name) : public nld_truthtable_t<_nIN, _nOUT, _state> \ @@ -44,10 +45,10 @@ struct truthtable_desc_t { } - ATTR_COLD void setup(const char **truthtable, UINT32 disabled_ignore); + ATTR_COLD void setup(const pstring_list_t &desc, UINT32 disabled_ignore); private: - ATTR_COLD void help(unsigned cur, nl_util::pstring_list list, + ATTR_COLD void help(unsigned cur, pstring_list_t list, UINT64 state,UINT16 val, UINT8 *timing_index); static unsigned count_bits(UINT32 v); static UINT32 set_bits(UINT32 v, UINT32 b); @@ -89,28 +90,40 @@ public: }; nld_truthtable_t(truthtable_t *ttbl, const char *desc[]) - : netlist_device_t(), m_last_state(0), m_ign(0), m_active(1), m_ttp(ttbl), m_desc(desc) + : netlist_device_t(), m_last_state(0), m_ign(0), m_active(1), m_ttp(ttbl) { + while (*desc != NULL && **desc != 0 ) + { + m_desc.add(*desc); + desc++; + } + + } + + nld_truthtable_t(truthtable_t *ttbl, const pstring_list_t &desc) + : netlist_device_t(), m_last_state(0), m_ign(0), m_active(1), m_ttp(ttbl) + { + m_desc = desc; } /* ATTR_COLD */ virtual void start() { - pstring ttline = pstring(m_desc[0]); + pstring header = m_desc[0]; - nl_util::pstring_list io = nl_util::split(ttline,"|"); + pstring_list_t io(header,"|"); // checks nl_assert_always(io.size() == 2, "too many '|'"); - nl_util::pstring_list inout = nl_util::split(io[0], ","); + pstring_list_t inout(io[0], ","); nl_assert_always(inout.size() == m_num_bits, "bitcount wrong"); - nl_util::pstring_list out = nl_util::split(io[1], ","); + pstring_list_t out(io[1], ","); nl_assert_always(out.size() == m_NO, "output count wrong"); - for (int i=0; i < m_NI; i++) + for (unsigned i=0; i < m_NI; i++) { inout[i] = inout[i].trim(); register_input(inout[i], m_i[i]); } - for (int i=0; i < m_NO; i++) + for (unsigned i=0; i < m_NO; i++) { out[i] = out[i].trim(); register_output(out[i], m_Q[i]); @@ -118,7 +131,7 @@ public: // Connect output "Q" to input "_Q" if this exists // This enables timed state without having explicit state .... UINT32 disabled_ignore = 0; - for (int i=0; i < m_NO; i++) + for (unsigned i=0; i < m_NO; i++) { pstring tmp = "_" + out[i]; const int idx = inout.indexof(tmp); @@ -154,7 +167,7 @@ public: ATTR_COLD void reset() { m_active = 0; - for (int i=0; i<m_NO;i++) + for (unsigned i=0; i<m_NO;i++) if (this->m_Q[i].net().num_cons()>0) m_active++; m_last_state = 0; @@ -193,14 +206,14 @@ public: const UINT32 timebase = nstate * m_NO; if (doOUT) { - for (int i = 0; i < m_NO; i++) + for (unsigned i = 0; i < m_NO; i++) OUTLOGIC(m_Q[i], (out >> i) & 1, m_ttp->m_timing_nt[m_ttp->m_timing[timebase + i]]); } else - for (int i = 0; i < m_NO; i++) + for (unsigned i = 0; i < m_NO; i++) m_Q[i].net().set_Q_time((out >> i) & 1, mt + m_ttp->m_timing_nt[m_ttp->m_timing[timebase + i]]); - for (int i = 0; i < m_NI; i++) + for (unsigned i = 0; i < m_NI; i++) if (m_ign & (1 << i)) m_i[i].inactivate(); @@ -227,7 +240,7 @@ public: if (has_state == 0) if (--m_active == 0) { - for (int i = 0; i< m_NI; i++) + for (unsigned i = 0; i< m_NI; i++) m_i[i].inactivate(); } } @@ -242,10 +255,60 @@ private: INT32 m_active; truthtable_t *m_ttp; - const char **m_desc; + pstring_list_t m_desc; +}; + +class netlist_base_factory_truthtable_t : public netlist_base_factory_t +{ + NETLIST_PREVENT_COPYING(netlist_base_factory_truthtable_t) +public: + ATTR_COLD netlist_base_factory_truthtable_t(const pstring &name, const pstring &classname, + const pstring &def_param) + : netlist_base_factory_t(name, classname, def_param) + {} + pstring_list_t m_desc; +}; + + +template<unsigned m_NI, unsigned m_NO, int has_state> +class netlist_factory_truthtable_t : public netlist_base_factory_truthtable_t +{ + NETLIST_PREVENT_COPYING(netlist_factory_truthtable_t) +public: + ATTR_COLD netlist_factory_truthtable_t(const pstring &name, const pstring &classname, + const pstring &def_param) + : netlist_base_factory_truthtable_t(name, classname, def_param) { } + + ATTR_COLD netlist_device_t *Create() + { + typedef nld_truthtable_t<m_NI, m_NO, has_state> tt_type; + netlist_device_t *r = palloc(tt_type, &m_ttbl, m_desc); + //r->init(setup, name); + return r; + } +private: + typename nld_truthtable_t<m_NI, m_NO, has_state>::truthtable_t m_ttbl; }; +netlist_base_factory_truthtable_t *nl_tt_factory_create(const unsigned ni, const unsigned no, + const unsigned has_state, + const pstring &name, const pstring &classname, + const pstring &def_param); + +#define TRUTHTABLE_START(_name, _in, _out, _has_state, _def_params) \ + { \ + netlist_base_factory_truthtable_t *ttd = nl_tt_factory_create(_in, _out, _has_state, \ + # _name, # _name, "+" _def_params); +#define TT_HEAD(_x) \ + ttd->m_desc.add(_x); + +#define TT_LINE(_x) \ + ttd->m_desc.add(_x); + +#define TRUTHTABLE_END() \ + setup.factory().register_device(ttd); \ + } #endif /* NLD_TRUTHTABLE_H_ */ diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c index 0a8da9fda8b..1bc33ed7e37 100644 --- a/src/emu/netlist/nl_base.c +++ b/src/emu/netlist/nl_base.c @@ -7,12 +7,11 @@ #include <cstring> -#include "palloc.h" +#include "plib/palloc.h" #include "nl_base.h" #include "devices/nld_system.h" #include "analog/nld_solver.h" -#include "pstring.h" #include "nl_util.h" const netlist_time netlist_time::zero = netlist_time::from_raw(0); diff --git a/src/emu/netlist/nl_base.h b/src/emu/netlist/nl_base.h index a293ec95dd4..a20309f7566 100644 --- a/src/emu/netlist/nl_base.h +++ b/src/emu/netlist/nl_base.h @@ -158,8 +158,7 @@ #include "nl_lists.h" #include "nl_time.h" #include "nl_util.h" -#include "pstring.h" -#include "pstate.h" +#include "plib/pstate.h" // ---------------------------------------------------------------------------------------- // Type definitions @@ -1197,7 +1196,7 @@ public: plist_t<_C *> get_device_list() { plist_t<_C *> tmp; - for (int i = 0; i < m_devices.size(); i++) + for (std::size_t i = 0; i < m_devices.size(); i++) { _C *dev = dynamic_cast<_C *>(m_devices[i]); if (dev != NULL) @@ -1209,7 +1208,7 @@ public: template<class _C> _C *get_first_device() { - for (int i = 0; i < m_devices.size(); i++) + for (std::size_t i = 0; i < m_devices.size(); i++) { _C *dev = dynamic_cast<_C *>(m_devices[i]); if (dev != NULL) @@ -1222,7 +1221,7 @@ public: _C *get_single_device(const char *classname) { _C *ret = NULL; - for (int i = 0; i < m_devices.size(); i++) + for (std::size_t i = 0; i < m_devices.size(); i++) { _C *dev = dynamic_cast<_C *>(m_devices[i]); if (dev != NULL) diff --git a/src/emu/netlist/nl_config.h b/src/emu/netlist/nl_config.h index d01f6154e92..7d14be13c53 100644 --- a/src/emu/netlist/nl_config.h +++ b/src/emu/netlist/nl_config.h @@ -8,7 +8,7 @@ #ifndef NLCONFIG_H_ #define NLCONFIG_H_ -#include "pconfig.h" +#include "plib/pconfig.h" //============================================================ // SETUP @@ -101,7 +101,7 @@ #if (NL_VERBOSE) #define NL_VERBOSE_OUT(x) printf x #else - #define NL_VERBOSE_OUT(x) do { } while (0) + #define NL_VERBOSE_OUT(x) do { if(0) printf x ; } while (0) #endif //============================================================ diff --git a/src/emu/netlist/nl_factory.c b/src/emu/netlist/nl_factory.c index 4c611af4c18..15ccbc62b5e 100644 --- a/src/emu/netlist/nl_factory.c +++ b/src/emu/netlist/nl_factory.c @@ -15,42 +15,42 @@ // net_device_t_base_factory // ---------------------------------------------------------------------------------------- -ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::term_param_list() +ATTR_COLD const pstring_list_t netlist_base_factory_t::term_param_list() { if (m_def_param.startsWith("+")) - return nl_util::split(m_def_param.substr(1), ","); + return pstring_list_t(m_def_param.substr(1), ","); else - return nl_util::pstring_list(); + return pstring_list_t(); } -ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::def_params() +ATTR_COLD const pstring_list_t netlist_base_factory_t::def_params() { if (m_def_param.startsWith("+") || m_def_param.equals("-")) - return nl_util::pstring_list(); + return pstring_list_t(); else - return nl_util::split(m_def_param, ","); + return pstring_list_t(m_def_param, ","); } -netlist_factory_t::netlist_factory_t() +netlist_factory_list_t::netlist_factory_list_t() { } -netlist_factory_t::~netlist_factory_t() +netlist_factory_list_t::~netlist_factory_list_t() { for (std::size_t i=0; i < m_list.size(); i++) { - net_device_t_base_factory *p = m_list[i]; + netlist_base_factory_t *p = m_list[i]; pfree(p); } m_list.clear(); } -netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname) const +netlist_device_t *netlist_factory_list_t::new_device_by_classname(const pstring &classname) const { for (std::size_t i=0; i < m_list.size(); i++) { - net_device_t_base_factory *p = m_list[i]; + netlist_base_factory_t *p = m_list[i]; if (p->classname() == classname) { netlist_device_t *ret = p->Create(); @@ -61,17 +61,17 @@ netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &clas return NULL; // appease code analysis } -netlist_device_t *netlist_factory_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const +netlist_device_t *netlist_factory_list_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const { - net_device_t_base_factory *f = factory_by_name(name, setup); + netlist_base_factory_t *f = factory_by_name(name, setup); return f->Create(); } -net_device_t_base_factory * netlist_factory_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const +netlist_base_factory_t * netlist_factory_list_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const { for (std::size_t i=0; i < m_list.size(); i++) { - net_device_t_base_factory *p = m_list[i]; + netlist_base_factory_t *p = m_list[i]; if (p->name() == name) { return p; diff --git a/src/emu/netlist/nl_factory.h b/src/emu/netlist/nl_factory.h index 970a5024c5a..ff4c56ceff1 100644 --- a/src/emu/netlist/nl_factory.h +++ b/src/emu/netlist/nl_factory.h @@ -10,33 +10,32 @@ #define NLFACTORY_H_ #include "nl_config.h" -#include "palloc.h" -#include "plists.h" +#include "plib/palloc.h" +#include "plib/plists.h" #include "nl_base.h" -#include "pstring.h" // ----------------------------------------------------------------------------- // net_dev class factory // ----------------------------------------------------------------------------- -class net_device_t_base_factory +class netlist_base_factory_t { - NETLIST_PREVENT_COPYING(net_device_t_base_factory) + NETLIST_PREVENT_COPYING(netlist_base_factory_t) public: - ATTR_COLD net_device_t_base_factory(const pstring &name, const pstring &classname, + ATTR_COLD netlist_base_factory_t(const pstring &name, const pstring &classname, const pstring &def_param) : m_name(name), m_classname(classname), m_def_param(def_param) {} - /* ATTR_COLD */ virtual ~net_device_t_base_factory() {} + /* ATTR_COLD */ virtual ~netlist_base_factory_t() {} - /* ATTR_COLD */ virtual netlist_device_t *Create() const = 0; + /* ATTR_COLD */ virtual netlist_device_t *Create() = 0; ATTR_COLD const pstring &name() const { return m_name; } ATTR_COLD const pstring &classname() const { return m_classname; } ATTR_COLD const pstring ¶m_desc() const { return m_def_param; } - ATTR_COLD const nl_util::pstring_list term_param_list(); - ATTR_COLD const nl_util::pstring_list def_params(); + ATTR_COLD const pstring_list_t term_param_list(); + ATTR_COLD const pstring_list_t def_params(); protected: pstring m_name; /* device name */ @@ -45,15 +44,15 @@ protected: }; template <class C> -class net_device_t_factory : public net_device_t_base_factory +class net_list_factory_t : public netlist_base_factory_t { - NETLIST_PREVENT_COPYING(net_device_t_factory) + NETLIST_PREVENT_COPYING(net_list_factory_t) public: - ATTR_COLD net_device_t_factory(const pstring &name, const pstring &classname, + ATTR_COLD net_list_factory_t(const pstring &name, const pstring &classname, const pstring &def_param) - : net_device_t_base_factory(name, classname, def_param) { } + : netlist_base_factory_t(name, classname, def_param) { } - ATTR_COLD netlist_device_t *Create() const + ATTR_COLD netlist_device_t *Create() { netlist_device_t *r = palloc(C); //r->init(setup, name); @@ -61,24 +60,29 @@ public: } }; -class netlist_factory_t +class netlist_factory_list_t { public: - typedef plist_t<net_device_t_base_factory *> list_t; + typedef plist_t<netlist_base_factory_t *> list_t; - netlist_factory_t(); - ~netlist_factory_t(); + netlist_factory_list_t(); + ~netlist_factory_list_t(); template<class _C> ATTR_COLD void register_device(const pstring &name, const pstring &classname, const pstring &def_param) { - m_list.add(palloc(net_device_t_factory< _C >, name, classname, def_param)); + m_list.add(palloc(net_list_factory_t< _C >, name, classname, def_param)); + } + + ATTR_COLD void register_device(netlist_base_factory_t *factory) + { + m_list.add(factory); } ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname) const; ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const; - ATTR_COLD net_device_t_base_factory * factory_by_name(const pstring &name, netlist_setup_t &setup) const; + ATTR_COLD netlist_base_factory_t * factory_by_name(const pstring &name, netlist_setup_t &setup) const; const list_t &list() { return m_list; } diff --git a/src/emu/netlist/nl_parser.c b/src/emu/netlist/nl_parser.c index 7d7b29733be..c7eb527d15a 100644 --- a/src/emu/netlist/nl_parser.c +++ b/src/emu/netlist/nl_parser.c @@ -7,6 +7,7 @@ #include "nl_parser.h" #include "nl_factory.h" +#include "devices/nld_truthtable.h" //#undef NL_VERBOSE_OUT //#define NL_VERBOSE_OUT(x) printf x @@ -33,7 +34,7 @@ bool netlist_parser::parse(const char *buf, const pstring nlname) reset(m_buf); set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"); - set_number_chars("01234567890eE-."); //FIXME: processing of numbers + set_number_chars(".0123456789", "0123456789eE-."); //FIXME: processing of numbers char ws[5]; ws[0] = ' '; ws[1] = 9; @@ -54,6 +55,10 @@ bool netlist_parser::parse(const char *buf, const pstring nlname) m_tok_SUBMODEL = register_token("SUBMODEL"); m_tok_NETLIST_START = register_token("NETLIST_START"); m_tok_NETLIST_END = register_token("NETLIST_END"); + m_tok_TRUTHTABLE_START = register_token("TRUTHTABLE_START"); + m_tok_TRUTHTABLE_END = register_token("TRUTHTABLE_END"); + m_tok_TT_HEAD = register_token("TT_HEAD"); + m_tok_TT_LINE = register_token("TT_LINE"); bool in_nl = false; @@ -119,6 +124,8 @@ void netlist_parser::parse_netlist(ATTR_UNUSED const pstring &nlname) net_submodel(); else if (token.is(m_tok_INCLUDE)) net_include(); + else if (token.is(m_tok_TRUTHTABLE_START)) + net_truthtable_start(); else if (token.is(m_tok_NETLIST_END)) { netdev_netlist_end(); @@ -129,6 +136,49 @@ void netlist_parser::parse_netlist(ATTR_UNUSED const pstring &nlname) } } +void netlist_parser::net_truthtable_start() +{ + pstring name = get_identifier(); + require_token(m_tok_comma); + unsigned ni = get_number_long(); + require_token(m_tok_comma); + unsigned no = get_number_long(); + require_token(m_tok_comma); + unsigned hs = get_number_long(); + require_token(m_tok_comma); + pstring def_param = get_string(); + require_token(m_tok_param_right); + + netlist_base_factory_truthtable_t *ttd = nl_tt_factory_create(ni, no, hs, + name, name, "+" + def_param); + + while (true) + { + token_t token = get_token(); + + if (token.is(m_tok_TT_HEAD)) + { + require_token(m_tok_param_left); + ttd->m_desc.add(get_string()); + require_token(m_tok_param_right); + } + else if (token.is(m_tok_TT_LINE)) + { + require_token(m_tok_param_left); + ttd->m_desc.add(get_string()); + require_token(m_tok_param_right); + } + else + { + require_token(token, m_tok_TRUTHTABLE_END); + require_token(m_tok_param_left); + require_token(m_tok_param_right); + m_setup.factory().register_device(ttd); + return; + } + } +} + void netlist_parser::netdev_netlist_start() { @@ -198,7 +248,7 @@ void netlist_parser::net_c() { pstring t1 = get_identifier(); m_setup.register_link(first , t1); - NL_VERBOSE_OUT(("Parser: Connect: %s %s\n", last.cstr(), t1.cstr())); + NL_VERBOSE_OUT(("Parser: Connect: %s %s\n", first.cstr(), t1.cstr())); token_t n = get_token(); if (n.is(m_tok_param_right)) break; @@ -223,10 +273,10 @@ void netlist_parser::netdev_param() void netlist_parser::device(const pstring &dev_type) { pstring devname; - net_device_t_base_factory *f = m_setup.factory().factory_by_name(dev_type, m_setup); + netlist_base_factory_t *f = m_setup.factory().factory_by_name(dev_type, m_setup); netlist_device_t *dev; - nl_util::pstring_list termlist = f->term_param_list(); - nl_util::pstring_list def_params = f->def_params(); + pstring_list_t termlist = f->term_param_list(); + pstring_list_t def_params = f->def_params(); std::size_t cnt; @@ -293,6 +343,23 @@ nl_double netlist_parser::eval_param(const token_t tok) for (i=1; i<6;i++) if (tok.str().equals(macs[i])) f = i; +#if 1 + if (f>0) + { + require_token(m_tok_param_left); + ret = get_number_double(); + require_token(m_tok_param_right); + } + else + { + val = tok.str(); + ret = val.as_double(&e); + if (e) + error("Error with parameter ...\n"); + } + return ret * facs[f]; + +#else if (f>0) { require_token(m_tok_param_left); @@ -308,4 +375,5 @@ nl_double netlist_parser::eval_param(const token_t tok) if (f>0) require_token(m_tok_param_right); return ret * facs[f]; +#endif } diff --git a/src/emu/netlist/nl_parser.h b/src/emu/netlist/nl_parser.h index 582aad49de7..8a600339981 100644 --- a/src/emu/netlist/nl_parser.h +++ b/src/emu/netlist/nl_parser.h @@ -10,7 +10,7 @@ #include "nl_setup.h" #include "nl_util.h" -#include "pparser.h" +#include "plib/pparser.h" class netlist_parser : public ptokenizer { @@ -31,6 +31,7 @@ public: void net_model(); void net_submodel(); void net_include(); + void net_truthtable_start(); protected: virtual void verror(pstring msg, int line_num, pstring line); @@ -49,6 +50,10 @@ private: token_id_t m_tok_NETLIST_END; token_id_t m_tok_SUBMODEL; token_id_t m_tok_INCLUDE; + token_id_t m_tok_TRUTHTABLE_START; + token_id_t m_tok_TRUTHTABLE_END; + token_id_t m_tok_TT_HEAD; + token_id_t m_tok_TT_LINE; netlist_setup_t &m_setup; diff --git a/src/emu/netlist/nl_setup.c b/src/emu/netlist/nl_setup.c index 6b98f14d452..94673f7d3f0 100644 --- a/src/emu/netlist/nl_setup.c +++ b/src/emu/netlist/nl_setup.c @@ -7,7 +7,7 @@ #include <cstdio> -#include "palloc.h" +#include "plib/palloc.h" #include "nl_base.h" #include "nl_setup.h" #include "nl_parser.h" @@ -39,7 +39,7 @@ netlist_setup_t::netlist_setup_t(netlist_base_t &netlist) , m_proxy_cnt(0) { netlist.set_setup(this); - m_factory = palloc(netlist_factory_t); + m_factory = palloc(netlist_factory_list_t); } void netlist_setup_t::init() @@ -286,7 +286,7 @@ void netlist_setup_t::register_object(netlist_device_t &dev, const pstring &name void netlist_setup_t::register_link_arr(const pstring &terms) { - nl_util::pstring_list list = nl_util::split(terms,", "); + pstring_list_t list(terms,", "); if (list.size() < 2) netlist().error("You must pass at least 2 terminals to NET_C"); for (std::size_t i = 1; i < list.size(); i++) @@ -776,8 +776,8 @@ void netlist_setup_t::start_devices() if (env != "") { NL_VERBOSE_OUT(("Creating dynamic logs ...\n")); - nl_util::pstring_list ll = nl_util::split(env, ":"); - for (std::size_t i=0; i < ll.size(); i++) + pstring_list_t ll(env, ":"); + for (unsigned i=0; i < ll.size(); i++) { NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr())); NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr())); diff --git a/src/emu/netlist/nl_setup.h b/src/emu/netlist/nl_setup.h index 311ca0bfa63..9219ee6581c 100644 --- a/src/emu/netlist/nl_setup.h +++ b/src/emu/netlist/nl_setup.h @@ -25,6 +25,10 @@ #define NET_REGISTER_DEV(_type, _name) \ setup.register_dev(NETLIB_NAME_STR(_type), # _name); +/* to be used to reference new library truthtable devices */ +#define NET_REGISTER_DEV_X(_type, _name) \ + setup.register_dev(# _type, # _name); + #define NET_REMOVE_DEV(_name) \ setup.remove_dev(# _name); @@ -66,7 +70,7 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &setup) // ---------------------------------------------------------------------------------------- // Forward definition so we keep nl_factory.h out of the public -class netlist_factory_t; +class netlist_factory_list_t; class netlist_setup_t { @@ -143,8 +147,8 @@ public: void namespace_push(const pstring &aname); void namespace_pop(); - netlist_factory_t &factory() { return *m_factory; } - const netlist_factory_t &factory() const { return *m_factory; } + netlist_factory_list_t &factory() { return *m_factory; } + const netlist_factory_list_t &factory() const { return *m_factory; } /* not ideal, but needed for save_state */ tagmap_terminal_t m_terminals; @@ -162,7 +166,7 @@ private: tagmap_link_t m_links; tagmap_nstring_t m_params_temp; - netlist_factory_t *m_factory; + netlist_factory_list_t *m_factory; plist_t<pstring> m_models; diff --git a/src/emu/netlist/nl_time.h b/src/emu/netlist/nl_time.h index 457f7622307..7b56b03628a 100644 --- a/src/emu/netlist/nl_time.h +++ b/src/emu/netlist/nl_time.h @@ -8,7 +8,7 @@ #define NLTIME_H_ #include "nl_config.h" -#include "pstate.h" +#include "plib/pstate.h" //============================================================ // MACROS diff --git a/src/emu/netlist/nl_util.h b/src/emu/netlist/nl_util.h index cf5ee6a3a7b..09a06ce976a 100644 --- a/src/emu/netlist/nl_util.h +++ b/src/emu/netlist/nl_util.h @@ -8,11 +8,12 @@ #ifndef NL_UTIL_H_ #define NL_UTIL_H_ -#include "pstring.h" -#include "plists.h" #include <cmath> #include <cstring> +#include "plib/pstring.h" +#include "plib/plists.h" + class nl_util { // this is purely static @@ -20,68 +21,7 @@ private: nl_util() {}; public: - typedef plist_t<pstring> pstring_list; - - static pstring_list split(const pstring &str, const pstring &onstr, bool ignore_empty = false) - { - pstring_list temp; - - int p = 0; - int pn; - - pn = str.find(onstr, p); - while (pn>=0) - { - pstring t = str.substr(p, pn - p); - if (!ignore_empty || t.len() != 0) - temp.add(t); - p = pn + onstr.len(); - pn = str.find(onstr, p); - } - if (p<str.len()) - { - pstring t = str.substr(p); - if (!ignore_empty || t.len() != 0) - temp.add(t); - } - return temp; - } - static pstring_list splitexpr(const pstring &str, const pstring_list &onstrl) - { - pstring_list temp; - pstring col = ""; - - int i = 0; - while (i<str.len()) - { - int p = -1; - for (std::size_t j=0; j < onstrl.size(); j++) - { - if (std::strncmp(onstrl[j].cstr(), &(str.cstr()[i]), onstrl[j].len())==0) - { - p = j; - break; - } - } - if (p>=0) - { - if (col != "") - temp.add(col); - col = ""; - temp.add(onstrl[p]); - i += onstrl[p].len(); - } - else - { - col += str.cstr()[i]; - i++; - } - } - if (col != "") - temp.add(col); - return temp; - } static const pstring environment(const pstring &var, const pstring &default_val = "") { diff --git a/src/emu/netlist/palloc.c b/src/emu/netlist/plib/palloc.c index 5f9dbc5fee7..5f9dbc5fee7 100644 --- a/src/emu/netlist/palloc.c +++ b/src/emu/netlist/plib/palloc.c diff --git a/src/emu/netlist/palloc.h b/src/emu/netlist/plib/palloc.h index e78bbc6e3ab..e78bbc6e3ab 100644 --- a/src/emu/netlist/palloc.h +++ b/src/emu/netlist/plib/palloc.h diff --git a/src/emu/netlist/pconfig.h b/src/emu/netlist/plib/pconfig.h index b05292b26e4..6c00cdd3411 100644 --- a/src/emu/netlist/pconfig.h +++ b/src/emu/netlist/plib/pconfig.h @@ -77,6 +77,23 @@ typedef int64_t INT64; #define S64(val) val #endif +/* MINGW has adopted the MSVC formatting for 64-bit ints as of gcc 4.4 */ +#if (defined(__MINGW32__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))) || defined(_MSC_VER) +#define I64FMT "I64" +#else +#define I64FMT "ll" +#endif + +#if defined(_MSC_VER) || defined(__MINGW32__) +#ifdef PTR64 +#define SIZETFMT "I64u" +#else +#define SIZETFMT "u" +#endif +#else +#define SIZETFMT "zu" +#endif + #endif #endif /* PCONFIG_H_ */ diff --git a/src/emu/netlist/plists.h b/src/emu/netlist/plib/plists.h index 25ded23fe83..fb121b798b6 100644 --- a/src/emu/netlist/plists.h +++ b/src/emu/netlist/plib/plists.h @@ -10,6 +10,8 @@ #ifndef PLISTS_H_ #define PLISTS_H_ +#include <cstring> + #include "palloc.h" #include "pstring.h" @@ -236,7 +238,7 @@ public: { //nl_assert((pos>=0) && (pos<m_count)); m_count--; - for (int i = pos; i < m_count; i++) + for (std::size_t i = pos; i < m_count; i++) { m_list[i] = m_list[i+1]; } @@ -339,7 +341,7 @@ class pnamedlist_t : public plist_t<_ListClass> public: _ListClass find(const pstring &name) const { - for (int i=0; i < this->size(); i++) + for (std::size_t i=0; i < this->size(); i++) if (get_name((*this)[i]) == name) return (*this)[i]; return _ListClass(NULL); @@ -510,4 +512,74 @@ private: _ListClass *m_head; }; +// ---------------------------------------------------------------------------------------- +// string list +// ---------------------------------------------------------------------------------------- + +class pstring_list_t : public plist_t<pstring> +{ +public: + pstring_list_t() : plist_t<pstring>() { } + + pstring_list_t(const pstring &str, const pstring &onstr, bool ignore_empty = false) + : plist_t<pstring>() + { + + int p = 0; + int pn; + + pn = str.find(onstr, p); + while (pn>=0) + { + pstring t = str.substr(p, pn - p); + if (!ignore_empty || t.len() != 0) + this->add(t); + p = pn + onstr.len(); + pn = str.find(onstr, p); + } + if (p<str.len()) + { + pstring t = str.substr(p); + if (!ignore_empty || t.len() != 0) + this->add(t); + } + } + + static pstring_list_t splitexpr(const pstring &str, const pstring_list_t &onstrl) + { + pstring_list_t temp; + pstring col = ""; + + int i = 0; + while (i<str.len()) + { + int p = -1; + for (std::size_t j=0; j < onstrl.size(); j++) + { + if (std::strncmp(onstrl[j].cstr(), &(str.cstr()[i]), onstrl[j].len())==0) + { + p = j; + break; + } + } + if (p>=0) + { + if (col != "") + temp.add(col); + col = ""; + temp.add(onstrl[p]); + i += onstrl[p].len(); + } + else + { + col += str.cstr()[i]; + i++; + } + } + if (col != "") + temp.add(col); + return temp; + } +}; + #endif /* PLISTS_H_ */ diff --git a/src/emu/netlist/poptions.h b/src/emu/netlist/plib/poptions.h index 7803a315d94..7803a315d94 100644 --- a/src/emu/netlist/poptions.h +++ b/src/emu/netlist/plib/poptions.h diff --git a/src/emu/netlist/pparser.c b/src/emu/netlist/plib/pparser.c index 8e58f0dcae7..95b9260c7cd 100644 --- a/src/emu/netlist/pparser.c +++ b/src/emu/netlist/plib/pparser.c @@ -96,6 +96,34 @@ pstring ptokenizer::get_identifier() return tok.str(); } +double ptokenizer::get_number_double() +{ + token_t tok = get_token(); + if (!tok.is_type(NUMBER)) + { + error("Error: expected a number, got <%s>\n", tok.str().cstr()); + } + bool err = false; + double ret = tok.str().as_double(&err); + if (err) + error("Error: expected a number, got <%s>\n", tok.str().cstr()); + return ret; +} + +long ptokenizer::get_number_long() +{ + token_t tok = get_token(); + if (!tok.is_type(NUMBER)) + { + error("Error: expected a long int, got <%s>\n", tok.str().cstr()); + } + bool err = false; + long ret = tok.str().as_long(&err); + if (err) + error("Error: expected a long int, got <%s>\n", tok.str().cstr()); + return ret; +} + ptokenizer::token_t ptokenizer::get_token() { while (true) @@ -135,7 +163,26 @@ ptokenizer::token_t ptokenizer::get_token_internal() return token_t(ENDOFFILE); } } - if (m_identifier_chars.find(c)>=0) + if (m_number_chars_start.find(c)>=0) + { + /* read number while we receive number or identifier chars + * treat it as an identifier when there are identifier chars in it + * + */ + token_type ret = NUMBER; + pstring tokstr = ""; + while (true) { + if (m_identifier_chars.find(c)>=0 && m_number_chars.find(c)<0) + ret = IDENTIFIER; + else if (m_number_chars.find(c)<0) + break; + tokstr += c; + c = getc(); + } + ungetc(); + return token_t(ret, tokstr); + } + else if (m_identifier_chars.find(c)>=0) { /* read identifier till non identifier char */ pstring tokstr = ""; @@ -218,6 +265,8 @@ ppreprocessor::ppreprocessor() m_expr_sep.add("=="); m_expr_sep.add(" "); m_expr_sep.add("\t"); + + m_defines.add(define_t("__PLIB_PREPROCESSOR__", "1")); } void ppreprocessor::error(const pstring &err) @@ -227,7 +276,7 @@ void ppreprocessor::error(const pstring &err) -double ppreprocessor::expr(const nl_util::pstring_list &sexpr, std::size_t &start, int prio) +double ppreprocessor::expr(const pstring_list_t &sexpr, std::size_t &start, int prio) { double val; pstring tok=sexpr[start]; @@ -300,7 +349,7 @@ ppreprocessor::define_t *ppreprocessor::get_define(const pstring &name) pstring ppreprocessor::replace_macros(const pstring &line) { - nl_util::pstring_list elems = nl_util::splitexpr(line, m_expr_sep); + pstring_list_t elems = pstring_list_t::splitexpr(line, m_expr_sep); pstringbuffer ret = ""; for (std::size_t i=0; i<elems.size(); i++) { @@ -313,7 +362,7 @@ pstring ppreprocessor::replace_macros(const pstring &line) return pstring(ret.cstr()); } -static pstring catremainder(const nl_util::pstring_list &elems, std::size_t start, pstring sep) +static pstring catremainder(const pstring_list_t &elems, std::size_t start, pstring sep) { pstringbuffer ret = ""; for (std::size_t i=start; i<elems.size(); i++) @@ -327,7 +376,7 @@ static pstring catremainder(const nl_util::pstring_list &elems, std::size_t star pstring ppreprocessor::process(const pstring &contents) { pstringbuffer ret = ""; - nl_util::pstring_list lines = nl_util::split(contents,"\n", false); + pstring_list_t lines(contents,"\n", false); UINT32 ifflag = 0; // 31 if levels int level = 0; @@ -336,15 +385,16 @@ pstring ppreprocessor::process(const pstring &contents) { pstring line = lines[i]; pstring lt = line.replace("\t"," ").trim(); - lt = replace_macros(lt); + // FIXME ... revise and extend macro handling if (lt.startsWith("#")) { - nl_util::pstring_list lti = nl_util::split(lt, " ", true); + pstring_list_t lti(lt, " ", true); if (lti[0].equals("#if")) { level++; std::size_t start = 0; - nl_util::pstring_list t = nl_util::splitexpr(lt.substr(3).replace(" ",""), m_expr_sep); + lt = replace_macros(lt); + pstring_list_t t = pstring_list_t::splitexpr(lt.substr(3).replace(" ",""), m_expr_sep); int val = expr(t, start, 0); if (val == 0) ifflag |= (1 << level); @@ -376,7 +426,7 @@ pstring ppreprocessor::process(const pstring &contents) } else if (lti[0].equals("#pragma")) { - if (lti.size() > 3 && lti[1].equals("NETLIST")) + if (ifflag == 0 && lti.size() > 3 && lti[1].equals("NETLIST")) { if (lti[2].equals("warning")) error("NETLIST: " + catremainder(lti, 3, " ")); @@ -384,9 +434,12 @@ pstring ppreprocessor::process(const pstring &contents) } else if (lti[0].equals("#define")) { - if (lti.size() != 3) - error(pstring::sprintf("PREPRO: only simple defines allowed: %s", line.cstr())); - m_defines.add(define_t(lti[1], lti[2])); + if (ifflag == 0) + { + if (lti.size() != 3) + error(pstring::sprintf("PREPRO: only simple defines allowed: %s", line.cstr())); + m_defines.add(define_t(lti[1], lti[2])); + } } else error(pstring::sprintf("unknown directive on line %" SIZETFMT ": %s\n", i, line.cstr())); @@ -395,9 +448,10 @@ pstring ppreprocessor::process(const pstring &contents) { //if (ifflag == 0 && level > 0) // fprintf(stderr, "conditional: %s\n", line.cstr()); + lt = replace_macros(lt); if (ifflag == 0) { - ret.cat(line); + ret.cat(lt); ret.cat("\n"); } } diff --git a/src/emu/netlist/pparser.h b/src/emu/netlist/plib/pparser.h index b44e83f649c..a9f538eeaef 100644 --- a/src/emu/netlist/pparser.h +++ b/src/emu/netlist/plib/pparser.h @@ -9,8 +9,8 @@ #define PPARSER_H_ #include "pconfig.h" -#include "nl_config.h" // FIXME -#include "nl_util.h" +#include "../nl_config.h" // FIXME +#include "../nl_util.h" class ptokenizer { @@ -86,6 +86,8 @@ public: token_t get_token(); pstring get_string(); pstring get_identifier(); + double get_number_double(); + long get_number_long(); void require_token(const token_id_t &token_num); void require_token(const token_t tok, const token_id_t &token_num); @@ -97,7 +99,7 @@ public: } void set_identifier_chars(pstring s) { m_identifier_chars = s; } - void set_number_chars(pstring s) { m_number_chars = s; } + void set_number_chars(pstring st, pstring rem) { m_number_chars_start = st; m_number_chars = rem; } void set_whitespace(pstring s) { m_whitespace = s; } void set_comment(pstring start, pstring end, pstring line) { @@ -129,6 +131,7 @@ private: pstring m_identifier_chars; pstring m_number_chars; + pstring m_number_chars_start; plist_t<pstring> m_tokens; pstring m_whitespace; char m_string; @@ -161,7 +164,7 @@ public: protected: - double expr(const nl_util::pstring_list &sexpr, std::size_t &start, int prio); + double expr(const pstring_list_t &sexpr, std::size_t &start, int prio); define_t *get_define(const pstring &name); @@ -172,7 +175,7 @@ protected: private: plist_t<define_t> m_defines; - nl_util::pstring_list m_expr_sep; + pstring_list_t m_expr_sep; }; #endif /* PPARSER_H_ */ diff --git a/src/emu/netlist/pstate.c b/src/emu/netlist/plib/pstate.c index 07532032405..07532032405 100644 --- a/src/emu/netlist/pstate.c +++ b/src/emu/netlist/plib/pstate.c diff --git a/src/emu/netlist/pstate.h b/src/emu/netlist/plib/pstate.h index 73b83e65a00..73b83e65a00 100644 --- a/src/emu/netlist/pstate.h +++ b/src/emu/netlist/plib/pstate.h diff --git a/src/emu/netlist/pstring.c b/src/emu/netlist/plib/pstring.c index ec930808e7b..ec930808e7b 100644 --- a/src/emu/netlist/pstring.c +++ b/src/emu/netlist/plib/pstring.c diff --git a/src/emu/netlist/pstring.h b/src/emu/netlist/plib/pstring.h index 7cfb936472c..7cfb936472c 100644 --- a/src/emu/netlist/pstring.h +++ b/src/emu/netlist/plib/pstring.h diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c index 225d3e396e1..e788b4fda34 100644 --- a/src/emu/sound/aica.c +++ b/src/emu/sound/aica.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:ElSemi, kingshriek, Deunan Knute, R. Belmont /* Sega/Yamaha AICA emulation diff --git a/src/emu/sound/aica.h b/src/emu/sound/aica.h index 25c6cb54fd1..0c7d5caf4f4 100644 --- a/src/emu/sound/aica.h +++ b/src/emu/sound/aica.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:ElSemi, kingshriek, Deunan Knute, R. Belmont /* diff --git a/src/emu/sound/aicadsp.c b/src/emu/sound/aicadsp.c index 7e8d4914171..4f533125825 100644 --- a/src/emu/sound/aicadsp.c +++ b/src/emu/sound/aicadsp.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:ElSemi, kingshriek, Deunan Knute, R. Belmont #include "emu.h" #include "aicadsp.h" diff --git a/src/emu/sound/aicadsp.h b/src/emu/sound/aicadsp.h index f5672e3dbd3..e28301a6100 100644 --- a/src/emu/sound/aicadsp.h +++ b/src/emu/sound/aicadsp.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:ElSemi, kingshriek, Deunan Knute, R. Belmont #pragma once diff --git a/src/emu/sound/disc_cls.h b/src/emu/sound/disc_cls.h index c03592a9f08..255b0958c15 100644 --- a/src/emu/sound/disc_cls.h +++ b/src/emu/sound/disc_cls.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:K.Wilkins, Derrick Renaud, F.Palazzolo, Couriersud #pragma once diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index d9bf63180db..61f3ea35242 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:K.Wilkins, Derrick Renaud, Frank Palazzolo, Couriersud /************************************************************************ * diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h index 921974193ab..a7dff7c7ff7 100644 --- a/src/emu/sound/discrete.h +++ b/src/emu/sound/discrete.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:K.Wilkins, Derrick Renaud, Frank Palazzolo, Couriersud #pragma once diff --git a/src/emu/sound/ics2115.c b/src/emu/sound/ics2115.c index c935616e115..d77410ad74b 100644 --- a/src/emu/sound/ics2115.c +++ b/src/emu/sound/ics2115.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Alex Marshall,nimitz,austere //ICS2115 by Raiden II team (c) 2010 //members: austere, nimitz, Alex Marshal diff --git a/src/emu/sound/ics2115.h b/src/emu/sound/ics2115.h index 5b810623df5..16d571fd997 100644 --- a/src/emu/sound/ics2115.h +++ b/src/emu/sound/ics2115.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Alex Marshall,nimitz,austere #pragma once diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c index 33aec56ae80..e27870108b5 100644 --- a/src/emu/sound/pokey.c +++ b/src/emu/sound/pokey.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Brad Oliver, Eric Smith, Juergen Buchmueller /***************************************************************************** * diff --git a/src/emu/sound/pokey.h b/src/emu/sound/pokey.h index 96c9f672246..c2cf13ba477 100644 --- a/src/emu/sound/pokey.h +++ b/src/emu/sound/pokey.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Brad Oliver, Eric Smith, Juergen Buchmueller /***************************************************************************** * diff --git a/src/emu/sound/qsound.c b/src/emu/sound/qsound.c index a3bbb1210f6..c519da454a5 100644 --- a/src/emu/sound/qsound.c +++ b/src/emu/sound/qsound.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Paul Leaman, Miguel Angel Horna /*************************************************************************** diff --git a/src/emu/sound/qsound.h b/src/emu/sound/qsound.h index 9d0697f406a..208fdac41e9 100644 --- a/src/emu/sound/qsound.h +++ b/src/emu/sound/qsound.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Paul Leaman, Miguel Angel Horna /********************************************************* diff --git a/src/emu/sound/tms5110.c b/src/emu/sound/tms5110.c index c1595b1caa7..03729598737 100644 --- a/src/emu/sound/tms5110.c +++ b/src/emu/sound/tms5110.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Frank Palazzolo, Jarek Burczynski, Aaron Giles, Jonathan Gevaryahu, Couriersud /********************************************************************************************** diff --git a/src/emu/sound/tms5110.h b/src/emu/sound/tms5110.h index 5addc3d967e..6196834a24a 100644 --- a/src/emu/sound/tms5110.h +++ b/src/emu/sound/tms5110.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Frank Palazzolo, Jarek Burczynski, Aaron Giles, Jonathan Gevaryahu, Couriersud #pragma once diff --git a/src/emu/sound/tms5220.c b/src/emu/sound/tms5220.c index 972780279f3..388862728ea 100644 --- a/src/emu/sound/tms5220.c +++ b/src/emu/sound/tms5220.c @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf /********************************************************************************************** diff --git a/src/emu/sound/tms5220.h b/src/emu/sound/tms5220.h index 7150ce5457b..6a9b36b723e 100644 --- a/src/emu/sound/tms5220.h +++ b/src/emu/sound/tms5220.h @@ -1,4 +1,4 @@ -// license:BSD-3-Clause +// license:??? // copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf #pragma once |