//template <typename M> public std.pair <size_t, size_t> gaussian_extend_fill_mat(std.vector <std.vector <unsigned> > fill) //std::pair<std::size_t, std::size_t> gaussian_extend_fill_mat(M &fill) { size_t ops = 0; size_t fill_max = 0; for (size_t k = 0; k < fill.size(); k++) { ops++; // 1/A(k,k) for (size_t row = k + 1; row < fill.size(); row++) { if (fill[row][k] < (size_t)pmatrix_cr <B, B_OPS, int_N> .constants_e.FILL_INFINITY) { ops++; for (size_t col = k + 1; col < fill[row].size(); col++) //if (fill[k][col] < FILL_INFINITY) { var f = std.min(fill[row][col], 1 + fill[row][k] + fill[k][col]); if (f < (size_t)pmatrix_cr <B, B_OPS, int_N> .constants_e.FILL_INFINITY) { if (f > fill_max) { fill_max = f; } ops += 2; } fill[row][col] = f; } } } } build_parallel_gaussian_execution_scheme(fill); return(new std.pair <size_t, size_t>(fill_max, ops)); }
/*------------------------------------------------- * presave - prepare data for save state * -------------------------------------------------*/ void presave() { for (size_t i = 0; m_save_order.size() > i; ++i) { m_save_data[i] = m_save_order[i].get(); } }
//UINT32 openflags() const { return m_openflags; } //------------------------------------------------- // hash - returns the hash for a file //------------------------------------------------- public util.hash_collection hashes(string types) { // determine the hashes we already have string already_have = m_hashes.hash_types(); // determine which hashes we need string needed = ""; foreach (char scan in types) { if (already_have.find_first_of(scan) == npos) { needed += scan; } } // if we need nothing, skip it if (string.IsNullOrEmpty(needed)) { return(m_hashes); } // load the ZIP file if needed if (compressed_file_ready()) { return(m_hashes); } if (m_file == null) { return(m_hashes); } // if we have ZIP data, just hash that directly if (!m_zipdata.empty()) { m_hashes.compute(new Pointer <u8>(m_zipdata), (uint32_t)m_zipdata.size(), needed); //m_hashes.compute(&m_zipdata[0], m_zipdata.size(), needed.c_str()); return(m_hashes); } // read the data if we can MemoryU8 filedata = m_file.buffer(); //const u8 *filedata = (const u8 *)m_file->buffer(); if (filedata == null) { return(m_hashes); } // compute the hash uint64_t length; if (!m_file.length(out length)) { m_hashes.compute(new PointerU8(filedata), (uint32_t)length, needed); } return(m_hashes); }
//------------------------------------------------- // actual_height //------------------------------------------------- public float actual_height() { line last_line = (m_lines.size() > 0) ? m_lines[m_lines.size() - 1] : null; return(last_line != null ? last_line.yoffset() + last_line.height() : 0); }
int get_net_idx(detail.net_t net) { for (UInt32 k = 0; k < m_nets.size(); k++) { if (m_nets[k] == net) { return((int)k); } } return(-1); }
public override void select_a(int id) //template<int HighBits, int Width, int AddrShift> void handler_entry_read_dispatch<HighBits, Width, AddrShift>::select_a(int id) { u32 i = (u32)id + 1; if (i >= m_dispatch_array.size()) { fatalerror("out-of-range view selection."); } m_a_ranges = m_ranges_array[i].data(); m_a_dispatch = m_dispatch_array[i].data(); }
//UINT32 openflags() const { return m_openflags; } //------------------------------------------------- // hash - returns the hash for a file //------------------------------------------------- public util.hash_collection hashes(string types) { // determine the hashes we already have string already_have = m_hashes.hash_types(); // determine which hashes we need string needed = ""; for (int scanIdx = 0; scanIdx < types.Length; scanIdx++) { if (already_have.IndexOf(types[scanIdx], 0) == -1) { needed += types[scanIdx]; } } // if we need nothing, skip it if (string.IsNullOrEmpty(needed)) { return(m_hashes); } // load the ZIP file if needed if (compressed_file_ready()) { return(m_hashes); } if (m_file == null) { return(m_hashes); } // if we have ZIP data, just hash that directly if (!m_zipdata.empty()) { m_hashes.compute(new ListBytesPointer(m_zipdata), (UInt32)m_zipdata.size(), needed.c_str()); return(m_hashes); } // read the data if we can ListBytes filedata = m_file.buffer(); if (filedata == null) { return(m_hashes); } // compute the hash m_hashes.compute(new ListBytesPointer(filedata), (UInt32)m_file.size(), needed); return(m_hashes); }
//------------------------------------------------- // line::truncate //------------------------------------------------- public void truncate(UInt32 position) { assert(position <= m_characters.size()); // are we actually truncating? if (position < m_characters.size()) { // set the width as appropriate m_width = m_characters[(int)position].xoffset; // and resize the array m_characters.resize((int)position); } }
// handle pre-saving by filling the blob protected override void device_pre_save() { // remember the original blob size var orig_size = m_save_blob.size(); // save the state ymfm.ymfm_saved_state state = new ymfm.ymfm_saved_state(m_save_blob, true); m_chip.save_restore(state); // ensure that the size didn't change since we first allocated if (m_save_blob.size() != orig_size) { throw new emu_fatalerror("State size changed for ymfm chip"); } }
public void add(terminal_t term, int net_other, bool sorted) { if (sorted) { for (int i = 0; i < m_connected_net_idx.size(); i++) { if (m_connected_net_idx[i] > net_other) { m_terms.Insert(i, term); //plib::container::insert_at(m_terms, i, term); m_connected_net_idx.Insert(i, net_other); //plib::container::insert_at(m_connected_net_idx, i, net_other); m_gt.Insert(i, 0.0); //plib::container::insert_at(m_gt, i, 0.0); m_go.Insert(i, 0.0); //plib::container::insert_at(m_go, i, 0.0); m_Idr.Insert(i, 0.0); //plib::container::insert_at(m_Idr, i, 0.0); m_connected_net_V.Insert(i, null); //plib::container::insert_at(m_connected_net_V, i, null); return; } } } m_terms.push_back(term); m_connected_net_idx.push_back(net_other); m_gt.push_back(0.0); m_go.push_back(0.0); m_Idr.push_back(0.0); m_connected_net_V.push_back(null); }
//void set_pen_colors(pen_t color_base, const rgb_t *colors, int color_count) { while (color_count--) set_pen_color(color_base++, *colors++); } //template <size_t N> void set_pen_colors(pen_t color_base, const rgb_t (&colors)[N]) { set_pen_colors(color_base, colors, N); } public void set_pen_colors(pen_t color_base, std.vector <rgb_t> colors) { for (int i = 0; i != colors.size(); i++) { set_pen_color(color_base + (pen_t)i, colors[i]); } }
// internal update helper void update_internal(std.vector <write_stream_view> outputs, int output_shift = 0) { // local buffer to hold samples int MAX_SAMPLES = 256; fm_engine_base <ChipClass_Registers, ChipClass_Registers_OPS> .output_data [] output = new fm_engine_base <ChipClass_Registers, ChipClass_Registers_OPS> .output_data[MAX_SAMPLES]; //typename ChipClass::output_data output[MAX_SAMPLES]; // parameters int outcount = (int)std.min(outputs.size(), std.size(output[0].data)); int numsamples = (int)outputs[0].samples(); // generate the FM/ADPCM stream for (int sampindex = 0; sampindex < numsamples; sampindex += MAX_SAMPLES) { int cursamples = std.min(numsamples - sampindex, MAX_SAMPLES); m_chip.generate(output, (uint32_t)cursamples); for (int outnum = 0; outnum < outcount; outnum++) { int eff_outnum = (outnum + output_shift) % OUTPUTS; for (int index = 0; index < cursamples; index++) { outputs[eff_outnum].put_int(sampindex + index, output[index].data[outnum], 32768); } } } }
//void transtable(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const UINT8 *pentable); //void transtable(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const UINT8 *pentable); //void alpha(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 transpen, UINT8 alpha); // ----- zoomed graphics drawing ----- // specific zoom implementations for each transparency type //void zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley); //void zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley); //void zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen); //void zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen); //void zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen); //void zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen); //void zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transmask); //void zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transmask); //void zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, const UINT8 *pentable); //void zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, const UINT8 *pentable); //void zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen, UINT8 alpha); // ----- priority masked graphics drawing ----- // specific prio implementations for each transparency type //void prio_opaque(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask); //void prio_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask); //void prio_transpen(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen); //void prio_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen); //void prio_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen); //void prio_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen); //void prio_transmask(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, UINT32 transmask); //void prio_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, UINT32 transmask); //void prio_transtable(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, const UINT8 *pentable); //void prio_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, const UINT8 *pentable); //void prio_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen, UINT8 alpha); // ----- priority masked zoomed graphics drawing ----- // specific prio_zoom implementations for each transparency type //void prio_zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask); //void prio_zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask); //void prio_zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen); //void prio_zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen); //void prio_zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen); //void prio_zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen); //void prio_zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, UINT32 transmask); //void prio_zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, UINT32 transmask); //void prio_zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, const UINT8 *pentable); //void prio_zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, const UINT8 *pentable); //void prio_zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, UINT32 transpen, UINT8 alpha); // implementations moved here from specific drivers //void prio_transpen_additive(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, UINT32 trans_pen); //void prio_zoom_transpen_additive(bitmap_rgb32 &dest, const rectangle &cliprect,UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask,UINT32 trans_pen); //void alphastore(bitmap_rgb32 &dest, const rectangle &cliprect,UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,int fixedalpha, UINT8 *alphatable); //void alphatable(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, int fixedalpha ,UINT8 *alphatable); // internal helpers //------------------------------------------------- // decode - decode a single character //------------------------------------------------- void decode(u32 code) { // don't decode GFX_RAW if (!m_layout_is_raw) { // zap the data to 0 ListBytesPointer decode_base = new ListBytesPointer(m_gfxdata, (int)(code * m_char_modulo)); //u8 *decode_base = m_gfxdata + code * m_char_modulo; memset(decode_base, (u8)0, m_char_modulo); //memset(decode_base, 0, m_char_modulo); // iterate over planes int plane; int planebit; for (plane = 0, planebit = 1 << (m_layout_planes - 1); plane < m_layout_planes; plane++, planebit >>= 1) { int planeoffs = (int)(code * m_layout_charincrement + m_layout_planeoffset[plane]); // iterate over rows for (int y = 0; y < m_origheight; y++) { int yoffs = (int)(planeoffs + m_layout_yoffset[y]); ListBytesPointer dp = new ListBytesPointer(decode_base, (int)(y * m_line_modulo)); //u8 *dp = decode_base + y * m_line_modulo; // iterate over columns for (int x = 0; x < m_origwidth; x++) { if (drawgfx_global.readbit(m_srcdata, (UInt32)((yoffs + m_layout_xoffset[x]) ^ m_layout_xormask)) != 0) { dp[x] |= (byte)planebit; } } } } } // (re)compute pen usage if (code < m_pen_usage.size()) { // iterate over data, creating a bitmask of live pens ListBytesPointer dp = new ListBytesPointer(m_gfxdata, (int)(code * m_char_modulo)); //const u8 *dp = m_gfxdata + code * m_char_modulo; u32 usage = 0; for (int y = 0; y < m_origheight; y++) { for (int x = 0; x < m_origwidth; x++) { usage |= 1U << dp[x]; } dp += m_line_modulo; } // store the final result m_pen_usage[(int)code] = usage; } // no longer dirty m_dirty[(int)code] = 0; }
// device startup //------------------------------------------------- // device_start - device startup //------------------------------------------------- protected override void device_start() { // precompute all gain-applied values for (s32 code = 0; code < (int)m_value_map.size(); code++) { m_value_map[code] = m_mapper((u32)code, m_bits) * m_gain; } // determine the number of inputs int inputs = (m_specified_inputs_mask == 0) ? 0 : 2; // create the stream m_stream = stream_alloc(inputs, 1, 48000 * 4); // save data save_item(NAME(new { m_curval })); }
// internal operation overrides //------------------------------------------------- // interface_post_start - verify that state was // properly set up //------------------------------------------------- public override void interface_post_start() { // make sure we got something during startup if (m_state_list.size() == 0) { throw new emu_fatalerror("No state registered for device '{0}' that supports it!\n", device().tag()); } }
//~queue_base() noexcept override = default; //queue_base(const queue_base &) = delete; //queue_base(queue_base &&) = delete; //queue_base &operator=(const queue_base &) = delete; //queue_base &operator=(queue_base &&) = delete; public void register_state(plib.state_manager_t manager, string module) { throw new emu_unimplemented(); #if false manager.save_item(this, m_qsize, module + "." + "qsize"); manager.save_item(this, &m_times[0], module + "." + "times", m_times.size()); manager.save_item(this, &m_net_ids[0], module + "." + "names", m_net_ids.size()); #endif }
//------------------------------------------------- // reset - clear the dirty array to mark all // entries as clean //------------------------------------------------- public void reset() { //throw new emu_unimplemented(); #if false // erase relevant entries in the new live one memset(&m_dirty[m_mindirty / 32], 0, ((m_maxdirty / 32) + 1 - (m_mindirty / 32)) * sizeof(UINT32)); #endif m_mindirty = (UInt32)(m_dirty.size() * 32 - 1); m_maxdirty = 0; }
//void set_raw_layout(const UINT8 *srcdata, UINT32 width, UINT32 height, UINT32 total, UINT32 linemod, UINT32 charmod); //void set_source(const UINT8 *source); //void set_source_and_total(const UINT8 *source, UINT32 total); //void set_xormask(UINT32 xormask) { m_layout_xormask = xormask; } //void set_palette(device_palette_interface *palette) { m_palette = palette; } //void set_colors(UINT32 colors) { m_total_colors = colors; } //void set_colorbase(UINT16 colorbase) { m_color_base = colorbase; } //void set_granularity(UINT16 granularity) { m_color_granularity = granularity; } //void set_source_clip(UINT32 xoffs, UINT32 width, UINT32 yoffs, UINT32 height); // operations //void mark_dirty(UINT32 code) { if (code < elements()) { m_dirty[code] = 1; m_dirtyseq++; } } //void mark_all_dirty() { memset(&m_dirty[0], 1, elements()); } public ListBytesPointer get_data(u32 code) //const u8 *get_data(u32 code) { //assert(code < elements()); if (code < m_dirty.size() && m_dirty[(int)code] != 0) { decode(code); } return(new ListBytesPointer(m_gfxdata, (int)(code * m_char_modulo + m_starty * m_line_modulo + m_startx))); }
void fill(memory_units_descriptor <int_Width, int_AddrShift> descriptor, std.vector <memory_units_descriptor <int_Width, int_AddrShift> .entry> entries) { handler_entry handler = descriptor.get_subunit_handler(); handler.ref_((int)entries.size()); foreach (var e in entries) { m_subunit_infos[m_subunits++] = new subunit_info(handler, e.m_amask, e.m_dmask, e.m_ashift, e.m_offset, e.m_dshift, descriptor.get_subunit_width()); } }
//------------------------------------------------- // reset - clear the dirty array to mark all // entries as clean //------------------------------------------------- public void reset() { //throw new emu_unimplemented(); #if false if (m_mindirty <= m_maxdirty) { std::fill(&m_dirty[m_mindirty / 32], &m_dirty[m_maxdirty / 32] + 1, 0); } #endif m_mindirty = (uint32_t)(m_dirty.size() * 32 - 1); m_maxdirty = 0; }
bool check_if_processed_and_join(analog_net_t n) { // no need to process rail nets - these are known variables if (n.is_rail_net()) { return(true); } // First check if it is in a previous group. // In this case we need to merge this group into the current group if (groupspre.size() > 1) { for (size_t i = 0; i < groupspre.size() - 1; i++) { if (plib.container.contains(groupspre[i], n)) { // copy all nets foreach (var cn in groupspre[i]) { if (!plib.container.contains(groupspre.back(), cn)) { groupspre.back().push_back(cn); } } // clear groupspre[i].clear(); return(true); } } } // if it's already processed - no need to continue if (!groupspre.empty() && plib.container.contains(groupspre.back(), n)) { return(true); } return(false); }
//------------------------------------------------- // set_indirect_color - set an indirect color //------------------------------------------------- public void set_indirect_color(int index, rgb_t rgb) { // make sure we are in range assert(index < m_indirect_colors.size()); // alpha doesn't matter rgb.set_a(255); // update if it has changed if (m_indirect_colors[index] != rgb) { m_indirect_colors[index] = rgb; // update the palette for any colortable entries that reference it for (UInt32 pen = 0; pen < m_indirect_pens.size(); pen++) { if (m_indirect_pens[(int)pen] == index) { m_palette.entry_set_color(pen, rgb); } } } }
netlist_time compute_next_timestep(double cur_ts) { nl_double new_solver_timestep = m_params.m_max_timestep; if (m_params.m_dynamic_ts) { for (int k = 0, iN = m_terms.size(); k < iN; k++) { analog_net_t n = m_nets[k]; terms_for_net_t t = m_terms[k].get(); nl_double DD_n = (n.Q_Analog() - t.last_V); nl_double hn = cur_ts; //printf("%f %f %f %f\n", DD_n, t->m_DD_n_m_1, hn, t->m_h_n_m_1); nl_double DD2 = (DD_n / hn - t.DD_n_m_1 / t.h_n_m_1) / (hn + t.h_n_m_1); nl_double new_net_timestep; t.h_n_m_1 = hn; t.DD_n_m_1 = DD_n; if (Math.Abs(DD2) > nl_config_global.NL_FCONST(1e-60)) // avoid div-by-zero { new_net_timestep = Math.Sqrt(m_params.m_dynamic_lte / Math.Abs(nl_config_global.NL_FCONST(0.5) * DD2)); } else { new_net_timestep = m_params.m_max_timestep; } if (new_net_timestep < new_solver_timestep) { new_solver_timestep = new_net_timestep; } t.last_V = n.Q_Analog(); } if (new_solver_timestep < m_params.m_min_timestep) { //log().warning("Dynamic timestep below min timestep. Consider decreasing MIN_TIMESTEP: {1} us", new_solver_timestep*1.0e6); new_solver_timestep = m_params.m_min_timestep; } } //if (new_solver_timestep > 10.0 * hn) // new_solver_timestep = 10.0 * hn; /* * FIXME: Factor 2 below is important. Without, we get timing issues. This must be a bug elsewhere. */ return(netlist_time.Max(netlist_time.from_double(new_solver_timestep), netlist_time.quantum() * 2)); }
static string catremainder(std.vector <string> elems, size_t start, string sep) { throw new emu_unimplemented(); #if false pstring ret(""); for (std::size_t i = start; i < elems.size(); i++) { ret += elems[i]; ret += sep; } return(ret); #endif }
//void set_scalar(const T scalar) //void set(C r, C c, T val) //template <typename M> public KeyValuePair <UInt32, UInt32> gaussian_extend_fill_mat(std.vector <std.vector <UInt32> > fill) //std::pair<std::size_t, std::size_t> gaussian_extend_fill_mat(M &fill) { UInt32 ops = 0; UInt32 fill_max = 0; for (UInt32 k = 0; k < fill.size(); k++) { ops++; // 1/A(k,k) for (UInt32 row = k + 1; row < fill.size(); row++) { if (fill[row][k] < FILL_INFINITY) { ops++; for (UInt32 col = k + 1; col < fill[row].size(); col++) { //if (fill[k][col] < FILL_INFINITY) { var f = std.min(fill[row][col], 1 + fill[row][k] + fill[k][col]); if (f < FILL_INFINITY) { if (f > fill_max) { fill_max = f; } ops += 2; } fill[row][col] = f; } } } } } return(new KeyValuePair <uint, uint>(fill_max, ops)); }
// sound interface overrides //------------------------------------------------- // sound_stream_update - mix all inputs to one // output //------------------------------------------------- public override void sound_stream_update(sound_stream stream, std.vector <read_stream_view> inputs, std.vector <write_stream_view> outputs) //virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; { // special case: single input, single output, same rate if (inputs.size() == 1 && outputs.size() == 1 && inputs[0].sample_rate() == outputs[0].sample_rate()) { outputs[0] = new write_stream_view(inputs[0]); //outputs[0] = inputs[0]; return; } // reset the clear flags std.fill(m_output_clear, false); //std::fill(std::begin(m_output_clear), std::end(m_output_clear), false); // loop over inputs for (int inputnum = 0; inputnum < m_auto_allocated_inputs; inputnum++) { // skip if the gain is 0 var input = inputs[inputnum]; if (input.gain() == 0) { continue; } // either store or accumulate int outputnum = m_outputmap[inputnum]; var output = outputs[outputnum]; if (!m_output_clear[outputnum]) { output.copy(input); } else { output.add(input); } m_output_clear[outputnum] = true; } // clear anything unused for (int outputnum = 0; outputnum < m_outputs; outputnum++) { if (!m_output_clear[outputnum]) { outputs[outputnum].fill(0); } } }
//template <typename T> public static std.vector <string> psplit(string str, std.vector <string> onstrl) //std::vector<T> psplit(const T &str, const std::vector<T> &onstrl) { string col = ""; //T col = ""; std.vector <string> ret = new std.vector <string>(); //std::vector<T> ret; size_t i = 0; //auto i = str.begin(); while (i != (size_t)str.Length) //while (i != str.end()) { size_t p = npos; //auto p = T::npos; for (size_t j = 0; j < onstrl.size(); j++) //for (std::size_t j=0; j < onstrl.size(); j++) { if (onstrl[j] == str.Substring((int)i, Math.Min(str.Length - (int)i, onstrl[j].Length))) //if (std::equal(onstrl[j].begin(), onstrl[j].end(), i)) { p = j; break; } } if (p != npos) //if (p != T::npos) { if (col != "") //if (!col.empty()) { ret.push_back(col); } col = ""; //col.clear(); ret.push_back(onstrl[p]); i += onstrl[p].length(); //i = std::next(i, narrow_cast<typename T::difference_type>(onstrl[p].length())); } else { char c = str[(int)i]; //typename T::value_type c = *i; col += c; i++; } } if (col != "") //if (!col.empty()) { ret.push_back(col); } return(ret); }
//void create_solver_code(std::map<pstring, pstring> &mp); //NETLIB_UPDATE(solver) protected override void update() { if (m_params.m_dynamic_ts) { return; } /* force solving during start up if there are no time-step devices */ /* FIXME: Needs a more elegant solution */ bool force_solve = (exec().time() < netlist_time.from_double(2 * m_params.m_max_timestep)); int nthreads = std.min(m_parallel.op(), plib.omp.pomp_global.get_max_threads()); std.vector <matrix_solver_t> solvers = force_solve ? m_mat_solvers : m_mat_solvers_timestepping; if (nthreads > 1 && solvers.size() > 1) { throw new emu_unimplemented(); #if false plib.omp.set_num_threads(nthreads); plib.omp.for_static(0, t_cnt, [this, &solv](int i) { netlist_time ts = this.m_mat_solvers[solv[i]].solve(); }); #endif } else { foreach (var solver in solvers) { netlist_time ts = solver.solve(); } } foreach (var solver in solvers) { solver.update_inputs(); } /* step circuit */ if (!m_Q_step.net().is_queued()) { m_Q_step.net().toggle_and_push_to_queue(netlist_time.from_double(m_params.m_max_timestep)); } }
// stream generation //------------------------------------------------- // sound_stream_update - stream updates //------------------------------------------------- protected virtual void device_sound_interface_sound_stream_update(sound_stream stream, std.vector <read_stream_view> inputs, std.vector <write_stream_view> outputs) //virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; { var out_ = outputs[0]; // rails are constant if (inputs.size() == 0) { out_.fill(m_range_min + m_curval * (m_range_max - m_range_min)); return; } var hi = inputs[DAC_INPUT_RANGE_HI]; var lo = inputs[DAC_INPUT_RANGE_LO]; // constant lo, streaming hi if (BIT(m_specified_inputs_mask, DAC_INPUT_RANGE_LO) == 0) { for (int sampindex = 0; sampindex < out_.samples(); sampindex++) { out_.put(sampindex, m_range_min + m_curval * (hi.get(sampindex) - m_range_min)); } } // constant hi, streaming lo else if (BIT(m_specified_inputs_mask, DAC_INPUT_RANGE_HI) == 0) { for (int sampindex = 0; sampindex < out_.samples(); sampindex++) { out_.put(sampindex, lo.get(sampindex) + m_curval * (m_range_max - lo.get(sampindex))); } } // both streams provided else { for (int sampindex = 0; sampindex < out_.samples(); sampindex++) { out_.put(sampindex, lo.get(sampindex) + m_curval * (hi.get(sampindex) - lo.get(sampindex))); } } }
protected void error(string errs) //void ptoken_reader::error(const perrmsg &errs) { string s = ""; string trail = " from "; string trail_first = "In file included from "; string e = new plib.pfmt("{0}:{1}:0: error: {2}\n") .op(m_source_location.back().file_name(), m_source_location.back().line(), errs); m_source_location.pop_back(); while (!m_source_location.empty()) { if (m_source_location.size() == 1) { trail = trail_first; } s = new plib.pfmt("{0}{1}:{2}:0\n{3}").op(trail, m_source_location.back().file_name(), m_source_location.back().line(), s); m_source_location.pop_back(); } verror("\n" + s + e + " " + m_line + "\n"); }