trunk/src/emu/luaengine.c
| r242997 | r242998 | |
| 1 | 1 | // license:BSD-3-Clause |
| 2 | | // copyright-holders:Miodrag Milanovic,Luca Bruno |
| 2 | // copyright-holders:Miodrag Milanovic |
| 3 | 3 | /*************************************************************************** |
| 4 | 4 | |
| 5 | 5 | luaengine.c |
| r242997 | r242998 | |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | //------------------------------------------------- |
| 459 | | // state_get_value - return value of a device state entry |
| 459 | // state_get_value - return value of a devices state |
| 460 | 460 | // -> manager:machine().devices[":maincpu"].state["PC"].value |
| 461 | 461 | //------------------------------------------------- |
| 462 | 462 | |
| 463 | 463 | UINT64 lua_engine::l_state_get_value(const device_state_entry *d) |
| 464 | 464 | { |
| 465 | | device_state_interface *state = d->parent_state(); |
| 466 | | if(state) { |
| 467 | | luaThis->machine().save().dispatch_presave(); |
| 468 | | return state->state_int(d->index()); |
| 469 | | } else { |
| 470 | | return 0; |
| 471 | | } |
| 465 | return d->value(); |
| 472 | 466 | } |
| 473 | 467 | |
| 474 | 468 | //------------------------------------------------- |
| 475 | | // state_set_value - set value of a device state entry |
| 469 | // state_set_value - set value of a devices state |
| 476 | 470 | // -> manager:machine().devices[":maincpu"].state["D0"].value = 0x0c00 |
| 477 | 471 | //------------------------------------------------- |
| 478 | 472 | |
| 479 | 473 | void lua_engine::l_state_set_value(device_state_entry *d, UINT64 val) |
| 480 | 474 | { |
| 481 | | device_state_interface *state = d->parent_state(); |
| 482 | | if(state) { |
| 483 | | state->set_state_int(d->index(), val); |
| 484 | | luaThis->machine().save().dispatch_presave(); |
| 485 | | } |
| 475 | d->set_value(val); |
| 486 | 476 | } |
| 487 | 477 | |
| 488 | 478 | //------------------------------------------------- |
| r242997 | r242998 | |
| 537 | 527 | } |
| 538 | 528 | |
| 539 | 529 | //------------------------------------------------- |
| 540 | | // mem_write - templated memory writer for <sign>,<size> |
| 541 | | // -> manager:machine().devices[":maincpu"].spaces["program"]:write_u16(0xC000, 0xF00D) |
| 542 | | //------------------------------------------------- |
| 543 | | |
| 544 | | template <typename T> |
| 545 | | int lua_engine::lua_addr_space::l_mem_write(lua_State *L) |
| 546 | | { |
| 547 | | address_space &sp = luabridge::Stack<address_space &>::get(L, 1); |
| 548 | | luaL_argcheck(L, lua_isnumber(L, 2), 2, "address (integer) expected"); |
| 549 | | luaL_argcheck(L, lua_isnumber(L, 3), 3, "value (integer) expected"); |
| 550 | | offs_t address = lua_tounsigned(L, 2); |
| 551 | | T val = lua_tounsigned(L, 3); |
| 552 | | |
| 553 | | switch(sizeof(val) * 8) { |
| 554 | | case 8: |
| 555 | | sp.write_byte(address, val); |
| 556 | | break; |
| 557 | | case 16: |
| 558 | | if ((address & 1) == 0) { |
| 559 | | sp.write_word(address, val); |
| 560 | | } else { |
| 561 | | sp.read_word_unaligned(address, val); |
| 562 | | } |
| 563 | | break; |
| 564 | | case 32: |
| 565 | | if ((address & 3) == 0) { |
| 566 | | sp.write_dword(address, val); |
| 567 | | } else { |
| 568 | | sp.write_dword_unaligned(address, val); |
| 569 | | } |
| 570 | | break; |
| 571 | | case 64: |
| 572 | | if ((address & 7) == 0) { |
| 573 | | sp.write_qword(address, val); |
| 574 | | } else { |
| 575 | | sp.write_qword_unaligned(address, val); |
| 576 | | } |
| 577 | | break; |
| 578 | | default: |
| 579 | | break; |
| 580 | | } |
| 581 | | |
| 582 | | return 0; |
| 583 | | } |
| 584 | | |
| 585 | | //------------------------------------------------- |
| 586 | | // screen_height - return screen visible height |
| 587 | | // -> manager:machine().screens[":screen"]:height() |
| 588 | | //------------------------------------------------- |
| 589 | | |
| 590 | | int lua_engine::lua_screen::l_height(lua_State *L) |
| 591 | | { |
| 592 | | screen_device *sc = luabridge::Stack<screen_device *>::get(L, 1); |
| 593 | | if(!sc) { |
| 594 | | return 0; |
| 595 | | } |
| 596 | | |
| 597 | | lua_pushunsigned(L, sc->visible_area().height()); |
| 598 | | return 1; |
| 599 | | } |
| 600 | | |
| 601 | | //------------------------------------------------- |
| 602 | | // screen_width - return screen visible width |
| 603 | | // -> manager:machine().screens[":screen"]:width() |
| 604 | | //------------------------------------------------- |
| 605 | | |
| 606 | | int lua_engine::lua_screen::l_width(lua_State *L) |
| 607 | | { |
| 608 | | screen_device *sc = luabridge::Stack<screen_device *>::get(L, 1); |
| 609 | | if(!sc) { |
| 610 | | return 0; |
| 611 | | } |
| 612 | | |
| 613 | | lua_pushunsigned(L, sc->visible_area().width()); |
| 614 | | return 1; |
| 615 | | } |
| 616 | | |
| 617 | | //------------------------------------------------- |
| 618 | 530 | // draw_box - draw a box on a screen container |
| 619 | 531 | // -> manager:machine().screens[":screen"]:draw_box(x1, y1, x2, y2, bgcolor, linecolor) |
| 620 | 532 | //------------------------------------------------- |
| r242997 | r242998 | |
| 636 | 548 | |
| 637 | 549 | // retrieve all parameters |
| 638 | 550 | float x1, y1, x2, y2; |
| 639 | | x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 640 | | y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 641 | | x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 642 | | y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 551 | x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f); |
| 552 | y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f); |
| 553 | x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->width()) , 1.0f); |
| 554 | y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->height()), 1.0f); |
| 643 | 555 | UINT32 bgcolor = lua_tounsigned(L, 6); |
| 644 | 556 | UINT32 fgcolor = lua_tounsigned(L, 7); |
| 645 | 557 | |
| r242997 | r242998 | |
| 672 | 584 | |
| 673 | 585 | // retrieve all parameters |
| 674 | 586 | float x1, y1, x2, y2; |
| 675 | | x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 676 | | y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 677 | | x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 678 | | y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 587 | x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f); |
| 588 | y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f); |
| 589 | x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->width()) , 1.0f); |
| 590 | y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->height()), 1.0f); |
| 679 | 591 | UINT32 color = lua_tounsigned(L, 6); |
| 680 | 592 | |
| 681 | 593 | // draw the line |
| r242997 | r242998 | |
| 701 | 613 | luaL_argcheck(L, lua_isstring(L, 4), 4, "message (string) expected"); |
| 702 | 614 | |
| 703 | 615 | // retrieve all parameters |
| 704 | | float x = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 705 | | float y = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 616 | float x = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f); |
| 617 | float y = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f); |
| 706 | 618 | const char *msg = luaL_checkstring(L,4); |
| 707 | 619 | // TODO: add optional parameters (colors, etc.) |
| 708 | 620 | |
| r242997 | r242998 | |
| 970 | 882 | .addCFunction ("read_u32", &lua_addr_space::l_mem_read<UINT32>) |
| 971 | 883 | .addCFunction ("read_i64", &lua_addr_space::l_mem_read<INT64>) |
| 972 | 884 | .addCFunction ("read_u64", &lua_addr_space::l_mem_read<UINT64>) |
| 973 | | .addCFunction ("write_i8", &lua_addr_space::l_mem_write<INT8>) |
| 974 | | .addCFunction ("write_u8", &lua_addr_space::l_mem_write<UINT8>) |
| 975 | | .addCFunction ("write_i16", &lua_addr_space::l_mem_write<INT16>) |
| 976 | | .addCFunction ("write_u16", &lua_addr_space::l_mem_write<UINT16>) |
| 977 | | .addCFunction ("write_i32", &lua_addr_space::l_mem_write<INT32>) |
| 978 | | .addCFunction ("write_u32", &lua_addr_space::l_mem_write<UINT32>) |
| 979 | | .addCFunction ("write_i64", &lua_addr_space::l_mem_write<INT64>) |
| 980 | | .addCFunction ("write_u64", &lua_addr_space::l_mem_write<UINT64>) |
| 981 | 885 | .endClass() |
| 982 | 886 | .deriveClass <address_space, lua_addr_space> ("addr_space") |
| 983 | 887 | .addFunction("name", &address_space::name) |
| r242997 | r242998 | |
| 986 | 890 | .addCFunction ("draw_box", &lua_screen::l_draw_box) |
| 987 | 891 | .addCFunction ("draw_line", &lua_screen::l_draw_line) |
| 988 | 892 | .addCFunction ("draw_text", &lua_screen::l_draw_text) |
| 989 | | .addCFunction ("height", &lua_screen::l_height) |
| 990 | | .addCFunction ("width", &lua_screen::l_width) |
| 991 | 893 | .endClass() |
| 992 | 894 | .deriveClass <screen_device, lua_screen> ("screen_dev") |
| 993 | | .addFunction ("frame_number", &screen_device::frame_number) |
| 994 | 895 | .addFunction ("name", &screen_device::name) |
| 995 | 896 | .addFunction ("shortname", &screen_device::shortname) |
| 996 | 897 | .addFunction ("tag", &screen_device::tag) |
| 898 | .addFunction ("height", &screen_device::height) |
| 899 | .addFunction ("width", &screen_device::width) |
| 997 | 900 | .endClass() |
| 998 | 901 | .beginClass <device_state_entry> ("dev_space") |
| 999 | 902 | .addFunction ("name", &device_state_entry::symbol) |
trunk/src/emu/machine/netlist.c
| r242997 | r242998 | |
| 48 | 48 | #include "netlist.h" |
| 49 | 49 | #include "netlist/nl_base.h" |
| 50 | 50 | #include "netlist/nl_setup.h" |
| 51 | | #include "netlist/nl_factory.h" |
| 52 | 51 | #include "netlist/devices/net_lib.h" |
| 53 | 52 | #include "debugger.h" |
| 54 | 53 | |
| r242997 | r242998 | |
| 135 | 134 | pstring dname = "OUT_" + m_in; |
| 136 | 135 | m_delegate.bind_relative_to(owner()->machine().root_device()); |
| 137 | 136 | NETLIB_NAME(analog_callback) *dev = downcast<NETLIB_NAME(analog_callback) *>( |
| 138 | | setup.register_dev("nld_analog_callback", dname)); |
| 137 | setup.factory().new_device_by_classname("nld_analog_callback", setup)); |
| 139 | 138 | |
| 139 | setup.register_dev(dev, dname); |
| 140 | 140 | dev->register_callback(m_delegate); |
| 141 | 141 | setup.register_link(dname + ".IN", m_in); |
| 142 | 142 | } |
| r242997 | r242998 | |
| 208 | 208 | { |
| 209 | 209 | NETLIB_NAME(sound_in) *snd_in = setup.netlist().get_first_device<NETLIB_NAME(sound_in)>(); |
| 210 | 210 | if (snd_in == NULL) |
| 211 | | snd_in = dynamic_cast<NETLIB_NAME(sound_in) *>(setup.register_dev("nld_sound_in", "STREAM_INPUT")); |
| 211 | { |
| 212 | snd_in = dynamic_cast<NETLIB_NAME(sound_in) *>(setup.factory().new_device_by_classname("nld_sound_in", setup)); |
| 213 | setup.register_dev(snd_in, "STREAM_INPUT"); |
| 214 | } |
| 212 | 215 | |
| 213 | 216 | pstring sparam = pstring::sprintf("STREAM_INPUT.CHAN%d", m_channel); |
| 214 | 217 | setup.register_param(sparam, m_param_name); |
| r242997 | r242998 | |
| 244 | 247 | |
| 245 | 248 | void netlist_mame_stream_output_t::custom_netlist_additions(netlist_setup_t &setup) |
| 246 | 249 | { |
| 247 | | //NETLIB_NAME(sound_out) *snd_out; |
| 250 | NETLIB_NAME(sound_out) *snd_out; |
| 248 | 251 | pstring sname = pstring::sprintf("STREAM_OUT_%d", m_channel); |
| 249 | 252 | |
| 250 | | //snd_out = dynamic_cast<NETLIB_NAME(sound_out) *>(setup.register_dev("nld_sound_out", sname)); |
| 251 | | setup.register_dev("nld_sound_out", sname); |
| 253 | snd_out = dynamic_cast<NETLIB_NAME(sound_out) *>(setup.factory().new_device_by_classname("nld_sound_out", setup)); |
| 254 | setup.register_dev(snd_out, sname); |
| 252 | 255 | |
| 253 | 256 | setup.register_param(sname + ".CHAN" , m_channel); |
| 254 | 257 | setup.register_param(sname + ".MULT", m_mult); |
| r242997 | r242998 | |
| 440 | 443 | if (td != NULL) save_pointer(td, s->m_name, s->m_count); |
| 441 | 444 | } |
| 442 | 445 | break; |
| 443 | | case DT_FLOAT: |
| 444 | | { |
| 445 | | float *td = s->resolved<float>(); |
| 446 | | if (td != NULL) save_pointer(td, s->m_name, s->m_count); |
| 447 | | } |
| 448 | | break; |
| 449 | 446 | case DT_INT64: |
| 450 | 447 | save_pointer((INT64 *) s->m_ptr, s->m_name, s->m_count); |
| 451 | 448 | break; |
trunk/src/emu/netlist/analog/nld_bjt.c
| r242997 | r242998 | |
| 11 | 11 | { |
| 12 | 12 | public: |
| 13 | 13 | diode() : m_Is(1e-15), m_VT(0.0258), m_VT_inv(1.0 / m_VT) {} |
| 14 | | diode(const nl_double Is, const nl_double n) |
| 14 | diode(const double Is, const double n) |
| 15 | 15 | { |
| 16 | 16 | m_Is = Is; |
| 17 | 17 | m_VT = 0.0258 * n; |
| 18 | 18 | m_VT_inv = 1.0 / m_VT; |
| 19 | 19 | } |
| 20 | | void set(const nl_double Is, const nl_double n) |
| 20 | void set(const double Is, const double n) |
| 21 | 21 | { |
| 22 | 22 | m_Is = Is; |
| 23 | 23 | m_VT = 0.0258 * n; |
| 24 | 24 | m_VT_inv = 1.0 / m_VT; |
| 25 | 25 | } |
| 26 | | nl_double I(const nl_double V) const { return m_Is * exp(V * m_VT_inv) - m_Is; } |
| 27 | | nl_double g(const nl_double V) const { return m_Is * m_VT_inv * exp(V * m_VT_inv); } |
| 28 | | nl_double V(const nl_double I) const { return log(1.0 + I / m_Is) * m_VT; } |
| 29 | | nl_double gI(const nl_double I) const { return m_VT_inv * (I + m_Is); } |
| 26 | double I(const double V) const { return m_Is * exp(V * m_VT_inv) - m_Is; } |
| 27 | double g(const double V) const { return m_Is * m_VT_inv * exp(V * m_VT_inv); } |
| 28 | double V(const double I) const { return log(1.0 + I / m_Is) * m_VT; } |
| 29 | double gI(const double I) const { return m_VT_inv * (I + m_Is); } |
| 30 | 30 | |
| 31 | 31 | private: |
| 32 | | nl_double m_Is; |
| 33 | | nl_double m_VT; |
| 34 | | nl_double m_VT_inv; |
| 32 | double m_Is; |
| 33 | double m_VT; |
| 34 | double m_VT_inv; |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | |
| r242997 | r242998 | |
| 85 | 85 | m_state_on = 0; |
| 86 | 86 | |
| 87 | 87 | { |
| 88 | | nl_double IS = m_model.model_value("IS", 1e-15); |
| 89 | | nl_double BF = m_model.model_value("BF", 100); |
| 90 | | nl_double NF = m_model.model_value("NF", 1); |
| 91 | | //nl_double VJE = m_model.dValue("VJE", 0.75); |
| 88 | double IS = m_model.model_value("IS", 1e-15); |
| 89 | double BF = m_model.model_value("BF", 100); |
| 90 | double NF = m_model.model_value("NF", 1); |
| 91 | //double VJE = m_model.dValue("VJE", 0.75); |
| 92 | 92 | |
| 93 | 93 | set_qtype((m_model.model_type() == "NPN") ? BJT_NPN : BJT_PNP); |
| 94 | 94 | |
| 95 | | nl_double alpha = BF / (1.0 + BF); |
| 95 | double alpha = BF / (1.0 + BF); |
| 96 | 96 | |
| 97 | 97 | diode d(IS, NF); |
| 98 | 98 | |
| r242997 | r242998 | |
| 155 | 155 | m_gD_BC.save("m_D_BC", *this); |
| 156 | 156 | |
| 157 | 157 | { |
| 158 | | nl_double IS = m_model.model_value("IS", 1e-15); |
| 159 | | nl_double BF = m_model.model_value("BF", 100); |
| 160 | | nl_double NF = m_model.model_value("NF", 1); |
| 161 | | nl_double BR = m_model.model_value("BR", 1); |
| 162 | | nl_double NR = m_model.model_value("NR", 1); |
| 163 | | //nl_double VJE = m_model.dValue("VJE", 0.75); |
| 158 | double IS = m_model.model_value("IS", 1e-15); |
| 159 | double BF = m_model.model_value("BF", 100); |
| 160 | double NF = m_model.model_value("NF", 1); |
| 161 | double BR = m_model.model_value("BR", 1); |
| 162 | double NR = m_model.model_value("NR", 1); |
| 163 | //double VJE = m_model.dValue("VJE", 0.75); |
| 164 | 164 | |
| 165 | 165 | set_qtype((m_model.model_type() == "NPN") ? BJT_NPN : BJT_PNP); |
| 166 | 166 | //printf("type %s\n", m_model.model_type().cstr()); |
trunk/src/emu/netlist/analog/nld_bjt.h
| r242997 | r242998 | |
| 98 | 98 | |
| 99 | 99 | NETLIB_UPDATE_TERMINALS() |
| 100 | 100 | { |
| 101 | | const nl_double m = (is_qtype( BJT_NPN) ? 1 : -1); |
| 101 | const double m = (is_qtype( BJT_NPN) ? 1 : -1); |
| 102 | 102 | |
| 103 | 103 | const int new_state = (m_RB.deltaV() * m > m_V ) ? 1 : 0; |
| 104 | 104 | if (m_state_on ^ new_state) |
| 105 | 105 | { |
| 106 | 106 | #if 0 |
| 107 | | nl_double gb = m_gB; |
| 108 | | nl_double gc = m_gC; |
| 109 | | nl_double v = m_V * m; |
| 107 | double gb = m_gB; |
| 108 | double gc = m_gC; |
| 109 | double v = m_V * m; |
| 110 | 110 | if (!new_state ) |
| 111 | 111 | { |
| 112 | 112 | // not conducting |
| r242997 | r242998 | |
| 115 | 115 | gc = netlist().gmin(); |
| 116 | 116 | } |
| 117 | 117 | #else |
| 118 | | const nl_double gb = new_state ? m_gB : netlist().gmin(); |
| 119 | | const nl_double gc = new_state ? m_gC : netlist().gmin(); |
| 120 | | const nl_double v = new_state ? m_V * m : 0; |
| 118 | const double gb = new_state ? m_gB : netlist().gmin(); |
| 119 | const double gc = new_state ? m_gC : netlist().gmin(); |
| 120 | const double v = new_state ? m_V * m : 0; |
| 121 | 121 | #endif |
| 122 | 122 | m_RB.set(gb, v, 0.0); |
| 123 | 123 | m_RC.set(gc, 0.0, 0.0); |
| r242997 | r242998 | |
| 142 | 142 | ATTR_COLD virtual void start(); |
| 143 | 143 | ATTR_HOT void update_param(); |
| 144 | 144 | |
| 145 | | nl_double m_gB; // base conductance / switch on |
| 146 | | nl_double m_gC; // collector conductance / switch on |
| 147 | | nl_double m_V; // internal voltage source |
| 145 | double m_gB; // base conductance / switch on |
| 146 | double m_gC; // collector conductance / switch on |
| 147 | double m_V; // internal voltage source |
| 148 | 148 | UINT8 m_state_on; |
| 149 | 149 | |
| 150 | 150 | private: |
| r242997 | r242998 | |
| 169 | 169 | |
| 170 | 170 | NETLIB_UPDATE_TERMINALS() |
| 171 | 171 | { |
| 172 | | const nl_double polarity = (qtype() == BJT_NPN ? 1.0 : -1.0); |
| 172 | const double polarity = (qtype() == BJT_NPN ? 1.0 : -1.0); |
| 173 | 173 | |
| 174 | 174 | m_gD_BE.update_diode(-m_D_EB.deltaV() * polarity); |
| 175 | 175 | m_gD_BC.update_diode(-m_D_CB.deltaV() * polarity); |
| 176 | 176 | |
| 177 | | const nl_double gee = m_gD_BE.G(); |
| 178 | | const nl_double gcc = m_gD_BC.G(); |
| 179 | | const nl_double gec = m_alpha_r * gcc; |
| 180 | | const nl_double gce = m_alpha_f * gee; |
| 181 | | const nl_double sIe = -m_gD_BE.I() + m_alpha_r * m_gD_BC.I(); |
| 182 | | const nl_double sIc = m_alpha_f * m_gD_BE.I() - m_gD_BC.I(); |
| 183 | | const nl_double Ie = (sIe + gee * m_gD_BE.Vd() - gec * m_gD_BC.Vd()) * polarity; |
| 184 | | const nl_double Ic = (sIc - gce * m_gD_BE.Vd() + gcc * m_gD_BC.Vd()) * polarity; |
| 177 | const double gee = m_gD_BE.G(); |
| 178 | const double gcc = m_gD_BC.G(); |
| 179 | const double gec = m_alpha_r * gcc; |
| 180 | const double gce = m_alpha_f * gee; |
| 181 | const double sIe = -m_gD_BE.I() + m_alpha_r * m_gD_BC.I(); |
| 182 | const double sIc = m_alpha_f * m_gD_BE.I() - m_gD_BC.I(); |
| 183 | const double Ie = (sIe + gee * m_gD_BE.Vd() - gec * m_gD_BC.Vd()) * polarity; |
| 184 | const double Ic = (sIc - gce * m_gD_BE.Vd() + gcc * m_gD_BC.Vd()) * polarity; |
| 185 | 185 | |
| 186 | 186 | m_D_EB.set_mat(gee, gec - gee, gce - gee, gee - gec, Ie, -Ie); |
| 187 | 187 | m_D_CB.set_mat(gcc, gce - gcc, gec - gcc, gcc - gce, Ic, -Ic); |
| r242997 | r242998 | |
| 202 | 202 | nld_twoterm m_D_EB; // gee, gec - gee, gce - gee, gee - gec | Ie |
| 203 | 203 | nld_twoterm m_D_EC; // 0, -gec, -gcc, 0 | 0 |
| 204 | 204 | |
| 205 | | nl_double m_alpha_f; |
| 206 | | nl_double m_alpha_r; |
| 205 | double m_alpha_f; |
| 206 | double m_alpha_r; |
| 207 | 207 | |
| 208 | 208 | private: |
| 209 | 209 | }; |
trunk/src/emu/netlist/analog/nld_ms_direct.h
| r242997 | r242998 | |
| 28 | 28 | protected: |
| 29 | 29 | ATTR_COLD virtual void add_term(int net_idx, netlist_terminal_t *term); |
| 30 | 30 | |
| 31 | | ATTR_HOT virtual nl_double vsolve(); |
| 31 | ATTR_HOT virtual double vsolve(); |
| 32 | 32 | |
| 33 | 33 | ATTR_HOT int solve_non_dynamic(); |
| 34 | 34 | ATTR_HOT void build_LE(); |
| 35 | | ATTR_HOT void gauss_LE(nl_double (* RESTRICT x)); |
| 36 | | ATTR_HOT nl_double delta(const nl_double (* RESTRICT V)); |
| 37 | | ATTR_HOT void store(const nl_double (* RESTRICT V), const bool store_RHS); |
| 35 | ATTR_HOT void gauss_LE(double (* RESTRICT x)); |
| 36 | ATTR_HOT double delta(const double (* RESTRICT V)); |
| 37 | ATTR_HOT void store(const double (* RESTRICT V), const bool store_RHS); |
| 38 | 38 | |
| 39 | 39 | /* bring the whole system to the current time |
| 40 | 40 | * Don't schedule a new calculation time. The recalculation has to be |
| 41 | 41 | * triggered by the caller after the netlist element was changed. |
| 42 | 42 | */ |
| 43 | | ATTR_HOT nl_double compute_next_timestep(); |
| 43 | ATTR_HOT double compute_next_timestep(); |
| 44 | 44 | |
| 45 | | nl_double m_A[_storage_N][((_storage_N + 7) / 8) * 8]; |
| 46 | | nl_double m_RHS[_storage_N]; |
| 47 | | nl_double m_last_RHS[_storage_N]; // right hand side - contains currents |
| 48 | | nl_double m_Vdelta[_storage_N]; |
| 49 | | nl_double m_last_V[_storage_N]; |
| 45 | double m_A[_storage_N][((_storage_N + 7) / 8) * 8]; |
| 46 | double m_RHS[_storage_N]; |
| 47 | double m_last_RHS[_storage_N]; // right hand side - contains currents |
| 48 | double m_Vdelta[_storage_N]; |
| 49 | double m_last_V[_storage_N]; |
| 50 | 50 | |
| 51 | 51 | terms_t **m_terms; |
| 52 | 52 | terms_t *m_rails_temp; |
| r242997 | r242998 | |
| 55 | 55 | vector_ops_t *m_row_ops[_storage_N + 1]; |
| 56 | 56 | |
| 57 | 57 | int m_dim; |
| 58 | | nl_double m_lp_fact; |
| 58 | double m_lp_fact; |
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | 61 | // ---------------------------------------------------------------------------------------- |
| r242997 | r242998 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | template <int m_N, int _storage_N> |
| 87 | | ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep() |
| 87 | ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep() |
| 88 | 88 | { |
| 89 | | nl_double new_solver_timestep = m_params.m_max_timestep; |
| 89 | double new_solver_timestep = m_params.m_max_timestep; |
| 90 | 90 | |
| 91 | 91 | if (m_params.m_dynamic) |
| 92 | 92 | { |
| r242997 | r242998 | |
| 103 | 103 | { |
| 104 | 104 | netlist_analog_net_t *n = m_nets[k]; |
| 105 | 105 | #endif |
| 106 | | const nl_double DD_n = (n->m_cur_Analog - m_last_V[k]); |
| 107 | | const nl_double hn = current_timestep(); |
| 106 | const double DD_n = (n->m_cur_Analog - m_last_V[k]); |
| 107 | const double hn = current_timestep(); |
| 108 | 108 | |
| 109 | | nl_double DD2 = (DD_n / hn - n->m_DD_n_m_1 / n->m_h_n_m_1) / (hn + n->m_h_n_m_1); |
| 110 | | nl_double new_net_timestep; |
| 109 | double DD2 = (DD_n / hn - n->m_DD_n_m_1 / n->m_h_n_m_1) / (hn + n->m_h_n_m_1); |
| 110 | double new_net_timestep; |
| 111 | 111 | |
| 112 | 112 | n->m_h_n_m_1 = hn; |
| 113 | 113 | n->m_DD_n_m_1 = DD_n; |
| r242997 | r242998 | |
| 236 | 236 | for (int i=0; i < N(); i++) |
| 237 | 237 | m_A[k][i] = 0.0; |
| 238 | 238 | |
| 239 | | nl_double rhsk = 0.0; |
| 240 | | nl_double akk = 0.0; |
| 239 | double rhsk = 0.0; |
| 240 | double akk = 0.0; |
| 241 | 241 | { |
| 242 | 242 | const int terms_count = m_terms[k]->count(); |
| 243 | | const nl_double * RESTRICT gt = m_terms[k]->gt(); |
| 244 | | const nl_double * RESTRICT go = m_terms[k]->go(); |
| 245 | | const nl_double * RESTRICT Idr = m_terms[k]->Idr(); |
| 243 | const double * RESTRICT gt = m_terms[k]->gt(); |
| 244 | const double * RESTRICT go = m_terms[k]->go(); |
| 245 | const double * RESTRICT Idr = m_terms[k]->Idr(); |
| 246 | 246 | #if VECTALT |
| 247 | 247 | |
| 248 | 248 | for (int i = 0; i < terms_count; i++) |
| r242997 | r242998 | |
| 253 | 253 | #else |
| 254 | 254 | m_terms[k]->ops()->sum2(Idr, gt, rhsk, akk); |
| 255 | 255 | #endif |
| 256 | | nl_double * const * RESTRICT other_cur_analog = m_terms[k]->other_curanalog(); |
| 256 | double * const * RESTRICT other_cur_analog = m_terms[k]->other_curanalog(); |
| 257 | 257 | for (int i = m_terms[k]->m_railstart; i < terms_count; i++) |
| 258 | 258 | { |
| 259 | 259 | //rhsk = rhsk + go[i] * terms[i]->m_otherterm->net().as_analog().Q_Analog(); |
| r242997 | r242998 | |
| 272 | 272 | m_A[k][k] += 1.0; |
| 273 | 273 | { |
| 274 | 274 | const int *net_other = m_terms[k]->net_other(); |
| 275 | | const nl_double *go = m_terms[k]->go(); |
| 275 | const double *go = m_terms[k]->go(); |
| 276 | 276 | const int railstart = m_terms[k]->m_railstart; |
| 277 | 277 | |
| 278 | 278 | for (int i = 0; i < railstart; i++) |
| r242997 | r242998 | |
| 285 | 285 | m_A[k][k] += akk; |
| 286 | 286 | { |
| 287 | 287 | const int * RESTRICT net_other = m_terms[k]->net_other(); |
| 288 | | const nl_double * RESTRICT go = m_terms[k]->go(); |
| 288 | const double * RESTRICT go = m_terms[k]->go(); |
| 289 | 289 | const int railstart = m_terms[k]->m_railstart; |
| 290 | 290 | |
| 291 | 291 | for (int i = 0; i < railstart; i++) |
| r242997 | r242998 | |
| 299 | 299 | |
| 300 | 300 | template <int m_N, int _storage_N> |
| 301 | 301 | ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::gauss_LE( |
| 302 | | nl_double (* RESTRICT x)) |
| 302 | double (* RESTRICT x)) |
| 303 | 303 | { |
| 304 | 304 | #if 0 |
| 305 | 305 | for (int i = 0; i < N(); i++) |
| r242997 | r242998 | |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /* FIXME: Singular matrix? */ |
| 339 | | const nl_double f = 1.0 / m_A[i][i]; |
| 339 | const double f = 1.0 / m_A[i][i]; |
| 340 | 340 | |
| 341 | 341 | /* Eliminate column i from row j */ |
| 342 | 342 | |
| 343 | 343 | for (int j = i + 1; j < kN; j++) |
| 344 | 344 | { |
| 345 | | const nl_double f1 = - m_A[j][i] * f; |
| 345 | const double f1 = - m_A[j][i] * f; |
| 346 | 346 | if (f1 != 0.0) |
| 347 | 347 | { |
| 348 | 348 | #if 0 && VECTALT |
| r242997 | r242998 | |
| 359 | 359 | /* back substitution */ |
| 360 | 360 | for (int j = kN - 1; j >= 0; j--) |
| 361 | 361 | { |
| 362 | | nl_double tmp = 0; |
| 362 | double tmp = 0; |
| 363 | 363 | |
| 364 | 364 | for (int k = j + 1; k < kN; k++) |
| 365 | 365 | tmp += m_A[j][k] * x[k]; |
| r242997 | r242998 | |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | template <int m_N, int _storage_N> |
| 383 | | ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta( |
| 384 | | const nl_double (* RESTRICT V)) |
| 383 | ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta( |
| 384 | const double (* RESTRICT V)) |
| 385 | 385 | { |
| 386 | | nl_double cerr = 0; |
| 387 | | nl_double cerr2 = 0; |
| 386 | double cerr = 0; |
| 387 | double cerr2 = 0; |
| 388 | 388 | for (int i = 0; i < this->N(); i++) |
| 389 | 389 | { |
| 390 | | const nl_double e = (V[i] - this->m_nets[i]->m_cur_Analog); |
| 391 | | const nl_double e2 = (m_RHS[i] - this->m_last_RHS[i]); |
| 390 | const double e = (V[i] - this->m_nets[i]->m_cur_Analog); |
| 391 | const double e2 = (m_RHS[i] - this->m_last_RHS[i]); |
| 392 | 392 | cerr = (fabs(e) > cerr ? fabs(e) : cerr); |
| 393 | 393 | cerr2 = (fabs(e2) > cerr2 ? fabs(e2) : cerr2); |
| 394 | 394 | } |
| r242997 | r242998 | |
| 398 | 398 | |
| 399 | 399 | template <int m_N, int _storage_N> |
| 400 | 400 | ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::store( |
| 401 | | const nl_double (* RESTRICT V), const bool store_RHS) |
| 401 | const double (* RESTRICT V), const bool store_RHS) |
| 402 | 402 | { |
| 403 | 403 | for (int i = 0; i < this->N(); i++) |
| 404 | 404 | { |
| r242997 | r242998 | |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | template <int m_N, int _storage_N> |
| 417 | | ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve() |
| 417 | ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve() |
| 418 | 418 | { |
| 419 | 419 | solve_base<netlist_matrix_solver_direct_t>(this); |
| 420 | 420 | return this->compute_next_timestep(); |
| r242997 | r242998 | |
| 424 | 424 | template <int m_N, int _storage_N> |
| 425 | 425 | ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic() |
| 426 | 426 | { |
| 427 | | nl_double new_v[_storage_N] = { 0.0 }; |
| 427 | double new_v[_storage_N] = { 0.0 }; |
| 428 | 428 | |
| 429 | 429 | this->gauss_LE(new_v); |
| 430 | 430 | |
| 431 | 431 | if (this->is_dynamic()) |
| 432 | 432 | { |
| 433 | | nl_double err = delta(new_v); |
| 433 | double err = delta(new_v); |
| 434 | 434 | |
| 435 | 435 | store(new_v, true); |
| 436 | 436 | |
trunk/src/emu/netlist/analog/nld_ms_gauss_seidel.h
| r242997 | r242998 | |
| 29 | 29 | |
| 30 | 30 | ATTR_HOT inline int vsolve_non_dynamic(); |
| 31 | 31 | protected: |
| 32 | | ATTR_HOT virtual nl_double vsolve(); |
| 32 | ATTR_HOT virtual double vsolve(); |
| 33 | 33 | |
| 34 | 34 | private: |
| 35 | | nl_double m_lp_fact; |
| 35 | double m_lp_fact; |
| 36 | 36 | int m_gs_fail; |
| 37 | 37 | int m_gs_total; |
| 38 | 38 | |
| r242997 | r242998 | |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | template <int m_N, int _storage_N> |
| 67 | | ATTR_HOT nl_double netlist_matrix_solver_gauss_seidel_t<m_N, _storage_N>::vsolve() |
| 67 | ATTR_HOT double netlist_matrix_solver_gauss_seidel_t<m_N, _storage_N>::vsolve() |
| 68 | 68 | { |
| 69 | 69 | /* |
| 70 | 70 | * enable linear prediction on first newton pass |
| r242997 | r242998 | |
| 86 | 86 | |
| 87 | 87 | if (USE_LINEAR_PREDICTION) |
| 88 | 88 | { |
| 89 | | nl_double sq = 0; |
| 90 | | nl_double sqo = 0; |
| 91 | | const nl_double rez_cts = 1.0 / this->current_timestep(); |
| 89 | double sq = 0; |
| 90 | double sqo = 0; |
| 91 | const double rez_cts = 1.0 / this->current_timestep(); |
| 92 | 92 | for (int k = 0; k < this->N(); k++) |
| 93 | 93 | { |
| 94 | 94 | const netlist_analog_net_t *n = this->m_nets[k]; |
| 95 | | const nl_double nv = (n->m_cur_Analog - this->m_last_V[k]) * rez_cts ; |
| 95 | const double nv = (n->m_cur_Analog - this->m_last_V[k]) * rez_cts ; |
| 96 | 96 | sq += nv * nv; |
| 97 | 97 | sqo += this->m_Vdelta[k] * this->m_Vdelta[k]; |
| 98 | 98 | this->m_Vdelta[k] = nv; |
| r242997 | r242998 | |
| 116 | 116 | */ |
| 117 | 117 | |
| 118 | 118 | #if 0 || USE_MATRIX_GS |
| 119 | | static nl_double ws = 1.0; |
| 120 | | ATTR_ALIGN nl_double new_v[_storage_N] = { 0.0 }; |
| 119 | static double ws = 1.0; |
| 120 | ATTR_ALIGN double new_v[_storage_N] = { 0.0 }; |
| 121 | 121 | const int iN = this->N(); |
| 122 | 122 | |
| 123 | 123 | bool resched = false; |
| r242997 | r242998 | |
| 127 | 127 | this->build_LE(); |
| 128 | 128 | |
| 129 | 129 | { |
| 130 | | nl_double frob; |
| 130 | double frob; |
| 131 | 131 | frob = 0; |
| 132 | | nl_double rmin = 1e99, rmax = -1e99; |
| 132 | double rmin = 1e99, rmax = -1e99; |
| 133 | 133 | for (int k = 0; k < iN; k++) |
| 134 | 134 | { |
| 135 | 135 | new_v[k] = this->m_nets[k]->m_cur_Analog; |
| 136 | | nl_double s=0.0; |
| 136 | double s=0.0; |
| 137 | 137 | for (int i = 0; i < iN; i++) |
| 138 | 138 | { |
| 139 | 139 | frob += this->m_A[k][i] * this->m_A[k][i]; |
| r242997 | r242998 | |
| 146 | 146 | rmax = s; |
| 147 | 147 | } |
| 148 | 148 | #if 0 |
| 149 | | nl_double frobA = sqrt(frob /(iN)); |
| 149 | double frobA = sqrt(frob /(iN)); |
| 150 | 150 | if (1 &&frobA < 1.0) |
| 151 | 151 | //ws = 2.0 / (1.0 + sqrt(1.0-frobA)); |
| 152 | 152 | ws = 2.0 / (2.0 - frobA); |
| r242997 | r242998 | |
| 161 | 161 | // overhead is bigger than the gain. Consequently the fast GS below |
| 162 | 162 | // uses a fixed GS. One can however use this here to determine a |
| 163 | 163 | // suitable parameter. |
| 164 | | nl_double rm = (rmax + rmin) * 0.5; |
| 164 | double rm = (rmax + rmin) * 0.5; |
| 165 | 165 | if (rm < 1.0) |
| 166 | 166 | ws = 2.0 / (1.0 + sqrt(1.0-rm)); |
| 167 | 167 | else |
| r242997 | r242998 | |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Frobenius norm for (D-L)^(-1)U |
| 175 | | //nl_double frobU; |
| 176 | | //nl_double frobL; |
| 177 | | //nl_double norm; |
| 175 | //double frobU; |
| 176 | //double frobL; |
| 177 | //double norm; |
| 178 | 178 | do { |
| 179 | 179 | resched = false; |
| 180 | | nl_double cerr = 0.0; |
| 180 | double cerr = 0.0; |
| 181 | 181 | //frobU = 0; |
| 182 | 182 | //frobL = 0; |
| 183 | 183 | //norm = 0; |
| 184 | 184 | |
| 185 | 185 | for (int k = 0; k < iN; k++) |
| 186 | 186 | { |
| 187 | | nl_double Idrive = 0; |
| 188 | | //nl_double norm_t = 0; |
| 187 | double Idrive = 0; |
| 188 | //double norm_t = 0; |
| 189 | 189 | // Reduction loops need -ffast-math |
| 190 | 190 | for (int i = 0; i < iN; i++) |
| 191 | 191 | Idrive += this->m_A[k][i] * new_v[i]; |
| r242997 | r242998 | |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | //if (norm_t > norm) norm = norm_t; |
| 201 | | const nl_double new_val = (1.0-ws) * new_v[k] + ws * (this->m_RHS[k] - Idrive + this->m_A[k][k] * new_v[k]) / this->m_A[k][k]; |
| 201 | const double new_val = (1.0-ws) * new_v[k] + ws * (this->m_RHS[k] - Idrive + this->m_A[k][k] * new_v[k]) / this->m_A[k][k]; |
| 202 | 202 | |
| 203 | | const nl_double e = fabs(new_val - new_v[k]); |
| 203 | const double e = fabs(new_val - new_v[k]); |
| 204 | 204 | cerr = (e > cerr ? e : cerr); |
| 205 | 205 | new_v[k] = new_val; |
| 206 | 206 | } |
| r242997 | r242998 | |
| 210 | 210 | resched = true; |
| 211 | 211 | } |
| 212 | 212 | resched_cnt++; |
| 213 | | //ATTR_UNUSED nl_double frobUL = sqrt((frobU + frobL) / (double) (iN) / (double) (iN)); |
| 213 | //ATTR_UNUSED double frobUL = sqrt((frobU + frobL) / (double) (iN) / (double) (iN)); |
| 214 | 214 | } while (resched && (resched_cnt < this->m_params.m_gs_loops)); |
| 215 | 215 | //printf("Frobenius %f %f %f %f %f\n", sqrt(frobU), sqrt(frobL), frobUL, frobA, norm); |
| 216 | 216 | //printf("Omega Estimate1 %f %f\n", 2.0 / (1.0 + sqrt(1-frobUL)), 2.0 / (1.0 + sqrt(1-frobA)) ); // printf("Frobenius %f\n", sqrt(frob / (double) (iN * iN) )); |
| r242997 | r242998 | |
| 247 | 247 | * omega = 2.0 / (1.0 + sqrt(1-rho)) |
| 248 | 248 | */ |
| 249 | 249 | |
| 250 | | const nl_double ws = this->m_params.m_sor; //1.045; //2.0 / (1.0 + /*sin*/(3.14159 * 5.5 / (double) (m_nets.count()+1))); |
| 251 | | //const nl_double ws = 2.0 / (1.0 + sin(3.14159 * 4 / (double) (this->N()))); |
| 250 | const double ws = this->m_params.m_sor; //1.045; //2.0 / (1.0 + /*sin*/(3.14159 * 5.5 / (double) (m_nets.count()+1))); |
| 251 | //const double ws = 2.0 / (1.0 + sin(3.14159 * 4 / (double) (this->N()))); |
| 252 | 252 | |
| 253 | | ATTR_ALIGN nl_double w[_storage_N]; |
| 254 | | ATTR_ALIGN nl_double one_m_w[_storage_N]; |
| 255 | | ATTR_ALIGN nl_double RHS[_storage_N]; |
| 256 | | ATTR_ALIGN nl_double new_V[_storage_N]; |
| 253 | ATTR_ALIGN double w[_storage_N]; |
| 254 | ATTR_ALIGN double one_m_w[_storage_N]; |
| 255 | ATTR_ALIGN double RHS[_storage_N]; |
| 256 | ATTR_ALIGN double new_V[_storage_N]; |
| 257 | 257 | |
| 258 | 258 | for (int k = 0; k < iN; k++) |
| 259 | 259 | { |
| 260 | | nl_double gtot_t = 0.0; |
| 261 | | nl_double gabs_t = 0.0; |
| 262 | | nl_double RHS_t = 0.0; |
| 260 | double gtot_t = 0.0; |
| 261 | double gabs_t = 0.0; |
| 262 | double RHS_t = 0.0; |
| 263 | 263 | |
| 264 | 264 | new_V[k] = this->m_nets[k]->m_cur_Analog; |
| 265 | 265 | |
| 266 | 266 | { |
| 267 | 267 | const int term_count = this->m_terms[k]->count(); |
| 268 | | const nl_double * const RESTRICT gt = this->m_terms[k]->gt(); |
| 269 | | const nl_double * const RESTRICT go = this->m_terms[k]->go(); |
| 270 | | const nl_double * const RESTRICT Idr = this->m_terms[k]->Idr(); |
| 271 | | const nl_double * const *other_cur_analog = this->m_terms[k]->other_curanalog(); |
| 268 | const double * const RESTRICT gt = this->m_terms[k]->gt(); |
| 269 | const double * const RESTRICT go = this->m_terms[k]->go(); |
| 270 | const double * const RESTRICT Idr = this->m_terms[k]->Idr(); |
| 271 | const double * const *other_cur_analog = this->m_terms[k]->other_curanalog(); |
| 272 | 272 | #if VECTALT |
| 273 | 273 | for (int i = 0; i < term_count; i++) |
| 274 | 274 | { |
| r242997 | r242998 | |
| 308 | 308 | |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | | const nl_double accuracy = this->m_params.m_accuracy; |
| 311 | const double accuracy = this->m_params.m_accuracy; |
| 312 | 312 | |
| 313 | 313 | do { |
| 314 | 314 | resched = false; |
| r242997 | r242998 | |
| 317 | 317 | { |
| 318 | 318 | const int * RESTRICT net_other = this->m_terms[k]->net_other(); |
| 319 | 319 | const int railstart = this->m_terms[k]->m_railstart; |
| 320 | | const nl_double * RESTRICT go = this->m_terms[k]->go(); |
| 320 | const double * RESTRICT go = this->m_terms[k]->go(); |
| 321 | 321 | |
| 322 | | nl_double Idrive = 0.0; |
| 322 | double Idrive = 0.0; |
| 323 | 323 | for (int i = 0; i < railstart; i++) |
| 324 | 324 | Idrive = Idrive + go[i] * new_V[net_other[i]]; |
| 325 | 325 | |
| 326 | | //nl_double new_val = (net->m_cur_Analog * gabs[k] + iIdr) / (gtot[k]); |
| 327 | | const nl_double new_val = new_V[k] * one_m_w[k] + (Idrive + RHS[k]) * w[k]; |
| 326 | //double new_val = (net->m_cur_Analog * gabs[k] + iIdr) / (gtot[k]); |
| 327 | const double new_val = new_V[k] * one_m_w[k] + (Idrive + RHS[k]) * w[k]; |
| 328 | 328 | |
| 329 | 329 | resched = resched || (std::abs(new_val - new_V[k]) > accuracy); |
| 330 | 330 | new_V[k] = new_val; |
trunk/src/emu/netlist/analog/nld_solver.c
| r242997 | r242998 | |
| 233 | 233 | |
| 234 | 234 | ATTR_COLD void netlist_matrix_solver_t::update() |
| 235 | 235 | { |
| 236 | | const nl_double new_timestep = solve(); |
| 236 | const double new_timestep = solve(); |
| 237 | 237 | |
| 238 | 238 | if (m_params.m_dynamic && is_timestep() && new_timestep > 0) |
| 239 | 239 | m_Q_sync.net().reschedule_in_queue(netlist_time::from_double(new_timestep)); |
| r242997 | r242998 | |
| 241 | 241 | |
| 242 | 242 | ATTR_COLD void netlist_matrix_solver_t::update_forced() |
| 243 | 243 | { |
| 244 | | ATTR_UNUSED const nl_double new_timestep = solve(); |
| 244 | ATTR_UNUSED const double new_timestep = solve(); |
| 245 | 245 | |
| 246 | 246 | if (m_params.m_dynamic && is_timestep()) |
| 247 | 247 | m_Q_sync.net().reschedule_in_queue(netlist_time::from_double(m_params.m_min_timestep)); |
| r242997 | r242998 | |
| 249 | 249 | |
| 250 | 250 | ATTR_HOT void netlist_matrix_solver_t::step(const netlist_time delta) |
| 251 | 251 | { |
| 252 | | const nl_double dd = delta.as_double(); |
| 252 | const double dd = delta.as_double(); |
| 253 | 253 | for (int k=0; k < m_step_devices.count(); k++) |
| 254 | 254 | m_step_devices[k]->step_time(dd); |
| 255 | 255 | } |
| r242997 | r242998 | |
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | | ATTR_HOT nl_double netlist_matrix_solver_t::solve() |
| 287 | ATTR_HOT double netlist_matrix_solver_t::solve() |
| 288 | 288 | { |
| 289 | 289 | netlist_time now = netlist().time(); |
| 290 | 290 | netlist_time delta = now - m_last_step; |
| r242997 | r242998 | |
| 300 | 300 | |
| 301 | 301 | step(delta); |
| 302 | 302 | |
| 303 | | const nl_double next_time_step = vsolve(); |
| 303 | const double next_time_step = vsolve(); |
| 304 | 304 | |
| 305 | 305 | update_inputs(); |
| 306 | 306 | return next_time_step; |
| r242997 | r242998 | |
| 348 | 348 | register_param("GMIN", m_gmin, NETLIST_GMIN_DEFAULT); |
| 349 | 349 | register_param("DYNAMIC_TS", m_dynamic, 0); |
| 350 | 350 | register_param("LTE", m_lte, 5e-5); // diff/timestep |
| 351 | | register_param("MIN_TIMESTEP", m_min_timestep, 1e-6); // nl_double timestep resolution |
| 351 | register_param("MIN_TIMESTEP", m_min_timestep, 1e-6); // double timestep resolution |
| 352 | 352 | |
| 353 | 353 | // internal staff |
| 354 | 354 | |
| r242997 | r242998 | |
| 417 | 417 | if (m_mat_solvers[i]->is_timestep()) |
| 418 | 418 | { |
| 419 | 419 | // Ignore return value |
| 420 | | ATTR_UNUSED const nl_double ts = m_mat_solvers[i]->solve(); |
| 420 | ATTR_UNUSED const double ts = m_mat_solvers[i]->solve(); |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | #endif |
trunk/src/emu/netlist/analog/nld_solver.h
| r242997 | r242998 | |
| 37 | 37 | |
| 38 | 38 | struct netlist_solver_parameters_t |
| 39 | 39 | { |
| 40 | | nl_double m_accuracy; |
| 41 | | nl_double m_lte; |
| 42 | | nl_double m_min_timestep; |
| 43 | | nl_double m_max_timestep; |
| 44 | | nl_double m_sor; |
| 40 | double m_accuracy; |
| 41 | double m_lte; |
| 42 | double m_min_timestep; |
| 43 | double m_max_timestep; |
| 44 | double m_sor; |
| 45 | 45 | bool m_dynamic; |
| 46 | 46 | int m_gs_loops; |
| 47 | 47 | int m_nr_loops; |
| r242997 | r242998 | |
| 59 | 59 | |
| 60 | 60 | virtual ~vector_ops_t() {} |
| 61 | 61 | |
| 62 | | virtual const nl_double sum(const nl_double * v) = 0; |
| 63 | | virtual void sum2(const nl_double * RESTRICT v1, const nl_double * RESTRICT v2, nl_double & RESTRICT s1, nl_double & RESTRICT s2) = 0; |
| 64 | | virtual void addmult(nl_double * RESTRICT v1, const nl_double * RESTRICT v2, const nl_double &mult) = 0; |
| 65 | | virtual void sum2a(const nl_double * RESTRICT v1, const nl_double * RESTRICT v2, const nl_double * RESTRICT v3abs, nl_double & RESTRICT s1, nl_double & RESTRICT s2, nl_double & RESTRICT s3abs) = 0; |
| 62 | virtual const double sum(const double * v) = 0; |
| 63 | virtual void sum2(const double * RESTRICT v1, const double * RESTRICT v2, double & RESTRICT s1, double & RESTRICT s2) = 0; |
| 64 | virtual void addmult(double * RESTRICT v1, const double * RESTRICT v2, const double &mult) = 0; |
| 65 | virtual void sum2a(const double * RESTRICT v1, const double * RESTRICT v2, const double * RESTRICT v3abs, double & RESTRICT s1, double & RESTRICT s2, double & RESTRICT s3abs) = 0; |
| 66 | 66 | |
| 67 | | virtual const nl_double sumabs(const nl_double * v) = 0; |
| 67 | virtual const double sumabs(const double * v) = 0; |
| 68 | 68 | |
| 69 | 69 | static vector_ops_t *create_ops(const int size); |
| 70 | 70 | |
| r242997 | r242998 | |
| 95 | 95 | |
| 96 | 96 | ATTR_HOT inline const int N() const { if (m_N == 0) return m_dim; else return m_N; } |
| 97 | 97 | |
| 98 | | const nl_double sum(const nl_double * v) |
| 98 | const double sum(const double * v) |
| 99 | 99 | { |
| 100 | | const nl_double * RESTRICT vl = v; |
| 101 | | nl_double tmp = 0.0; |
| 100 | const double * RESTRICT vl = v; |
| 101 | double tmp = 0.0; |
| 102 | 102 | for (int i=0; i < N(); i++) |
| 103 | 103 | tmp += vl[i]; |
| 104 | 104 | return tmp; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | | void sum2(const nl_double * RESTRICT v1, const nl_double * RESTRICT v2, nl_double & RESTRICT s1, nl_double & RESTRICT s2) |
| 107 | void sum2(const double * RESTRICT v1, const double * RESTRICT v2, double & RESTRICT s1, double & RESTRICT s2) |
| 108 | 108 | { |
| 109 | | const nl_double * RESTRICT v1l = v1; |
| 110 | | const nl_double * RESTRICT v2l = v2; |
| 109 | const double * RESTRICT v1l = v1; |
| 110 | const double * RESTRICT v2l = v2; |
| 111 | 111 | for (int i=0; i < N(); i++) |
| 112 | 112 | { |
| 113 | 113 | s1 += v1l[i]; |
| r242997 | r242998 | |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | | void addmult(nl_double * RESTRICT v1, const nl_double * RESTRICT v2, const nl_double &mult) |
| 118 | void addmult(double * RESTRICT v1, const double * RESTRICT v2, const double &mult) |
| 119 | 119 | { |
| 120 | | nl_double * RESTRICT v1l = v1; |
| 121 | | const nl_double * RESTRICT v2l = v2; |
| 120 | double * RESTRICT v1l = v1; |
| 121 | const double * RESTRICT v2l = v2; |
| 122 | 122 | for (int i=0; i < N(); i++) |
| 123 | 123 | { |
| 124 | 124 | v1l[i] += v2l[i] * mult; |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | | void sum2a(const nl_double * RESTRICT v1, const nl_double * RESTRICT v2, const nl_double * RESTRICT v3abs, nl_double & RESTRICT s1, nl_double & RESTRICT s2, nl_double & RESTRICT s3abs) |
| 128 | void sum2a(const double * RESTRICT v1, const double * RESTRICT v2, const double * RESTRICT v3abs, double & RESTRICT s1, double & RESTRICT s2, double & RESTRICT s3abs) |
| 129 | 129 | { |
| 130 | | const nl_double * RESTRICT v1l = v1; |
| 131 | | const nl_double * RESTRICT v2l = v2; |
| 132 | | const nl_double * RESTRICT v3l = v3abs; |
| 130 | const double * RESTRICT v1l = v1; |
| 131 | const double * RESTRICT v2l = v2; |
| 132 | const double * RESTRICT v3l = v3abs; |
| 133 | 133 | for (int i=0; i < N(); i++) |
| 134 | 134 | { |
| 135 | 135 | s1 += v1l[i]; |
| r242997 | r242998 | |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | | const nl_double sumabs(const nl_double * v) |
| 141 | const double sumabs(const double * v) |
| 142 | 142 | { |
| 143 | | const nl_double * RESTRICT vl = v; |
| 144 | | nl_double tmp = 0.0; |
| 143 | const double * RESTRICT vl = v; |
| 144 | double tmp = 0.0; |
| 145 | 145 | for (int i=0; i < N(); i++) |
| 146 | 146 | tmp += fabs(vl[i]); |
| 147 | 147 | return tmp; |
| r242997 | r242998 | |
| 171 | 171 | |
| 172 | 172 | ATTR_HOT inline netlist_terminal_t **terms() { return m_term; } |
| 173 | 173 | ATTR_HOT inline int *net_other() { return m_net_other; } |
| 174 | | ATTR_HOT inline nl_double *gt() { return m_gt; } |
| 175 | | ATTR_HOT inline nl_double *go() { return m_go; } |
| 176 | | ATTR_HOT inline nl_double *Idr() { return m_Idr; } |
| 177 | | ATTR_HOT inline nl_double **other_curanalog() { return m_other_curanalog; } |
| 174 | ATTR_HOT inline double *gt() { return m_gt; } |
| 175 | ATTR_HOT inline double *go() { return m_go; } |
| 176 | ATTR_HOT inline double *Idr() { return m_Idr; } |
| 177 | ATTR_HOT inline double **other_curanalog() { return m_other_curanalog; } |
| 178 | 178 | |
| 179 | 179 | ATTR_COLD void set_pointers(); |
| 180 | 180 | |
| r242997 | r242998 | |
| 183 | 183 | private: |
| 184 | 184 | plinearlist_t<netlist_terminal_t *> m_term; |
| 185 | 185 | plinearlist_t<int> m_net_other; |
| 186 | | plinearlist_t<nl_double> m_go; |
| 187 | | plinearlist_t<nl_double> m_gt; |
| 188 | | plinearlist_t<nl_double> m_Idr; |
| 189 | | plinearlist_t<nl_double *> m_other_curanalog; |
| 186 | plinearlist_t<double> m_go; |
| 187 | plinearlist_t<double> m_gt; |
| 188 | plinearlist_t<double> m_Idr; |
| 189 | plinearlist_t<double *> m_other_curanalog; |
| 190 | 190 | }; |
| 191 | 191 | |
| 192 | 192 | class netlist_matrix_solver_t : public netlist_device_t |
| r242997 | r242998 | |
| 209 | 209 | template<class C> |
| 210 | 210 | void solve_base(C *p); |
| 211 | 211 | |
| 212 | | ATTR_HOT nl_double solve(); |
| 212 | ATTR_HOT double solve(); |
| 213 | 213 | |
| 214 | 214 | ATTR_HOT inline bool is_dynamic() { return m_dynamic_devices.count() > 0; } |
| 215 | 215 | ATTR_HOT inline bool is_timestep() { return m_step_devices.count() > 0; } |
| r242997 | r242998 | |
| 236 | 236 | ATTR_HOT void update_dynamic(); |
| 237 | 237 | |
| 238 | 238 | // should return next time step |
| 239 | | ATTR_HOT virtual nl_double vsolve() = 0; |
| 239 | ATTR_HOT virtual double vsolve() = 0; |
| 240 | 240 | |
| 241 | 241 | ATTR_COLD virtual void add_term(int net_idx, netlist_terminal_t *term) = 0; |
| 242 | 242 | |
| r242997 | r242998 | |
| 249 | 249 | |
| 250 | 250 | const netlist_solver_parameters_t &m_params; |
| 251 | 251 | |
| 252 | | ATTR_HOT inline const nl_double current_timestep() { return m_cur_ts; } |
| 252 | ATTR_HOT inline const double current_timestep() { return m_cur_ts; } |
| 253 | 253 | private: |
| 254 | 254 | |
| 255 | 255 | netlist_time m_last_step; |
| 256 | | nl_double m_cur_ts; |
| 256 | double m_cur_ts; |
| 257 | 257 | dev_list_t m_step_devices; |
| 258 | 258 | dev_list_t m_dynamic_devices; |
| 259 | 259 | |
| r242997 | r242998 | |
| 279 | 279 | |
| 280 | 280 | ATTR_COLD void post_start(); |
| 281 | 281 | |
| 282 | | ATTR_HOT inline nl_double gmin() { return m_gmin.Value(); } |
| 282 | ATTR_HOT inline double gmin() { return m_gmin.Value(); } |
| 283 | 283 | |
| 284 | 284 | protected: |
| 285 | 285 | ATTR_HOT void update(); |
trunk/src/emu/netlist/analog/nld_twoterm.h
| r242997 | r242998 | |
| 97 | 97 | { |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | | ATTR_HOT inline void set(const nl_double G, const nl_double V, const nl_double I) |
| 100 | ATTR_HOT inline void set(const double G, const double V, const double I) |
| 101 | 101 | { |
| 102 | 102 | /* GO, GT, I */ |
| 103 | 103 | m_P.set( G, G, ( V) * G - I); |
| 104 | 104 | m_N.set( G, G, ( -V) * G + I); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | | ATTR_HOT inline nl_double deltaV() const |
| 107 | ATTR_HOT inline double deltaV() const |
| 108 | 108 | { |
| 109 | 109 | return m_P.net().as_analog().Q_Analog() - m_N.net().as_analog().Q_Analog(); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | | ATTR_HOT void set_mat(nl_double a11, nl_double a12, nl_double a21, nl_double a22, nl_double r1, nl_double r2) |
| 112 | ATTR_HOT void set_mat(double a11, double a12, double a21, double a22, double r1, double r2) |
| 113 | 113 | { |
| 114 | 114 | /* GO, GT, I */ |
| 115 | 115 | m_P.set(-a12, a11, -r1); |
| r242997 | r242998 | |
| 133 | 133 | public: |
| 134 | 134 | ATTR_COLD NETLIB_NAME(R_base)() : NETLIB_NAME(twoterm)(RESISTOR) { } |
| 135 | 135 | |
| 136 | | inline void set_R(const nl_double R) |
| 136 | inline void set_R(const double R) |
| 137 | 137 | { |
| 138 | 138 | set(1.0 / R, 0.0, 0.0); |
| 139 | 139 | } |
| r242997 | r242998 | |
| 171 | 171 | public: |
| 172 | 172 | ATTR_COLD NETLIB_NAME(C)() : NETLIB_NAME(twoterm)(CAPACITOR) { } |
| 173 | 173 | |
| 174 | | ATTR_HOT void step_time(const nl_double st) |
| 174 | ATTR_HOT void step_time(const double st) |
| 175 | 175 | { |
| 176 | | const nl_double G = m_C.Value() / st; |
| 177 | | const nl_double I = -G * deltaV(); |
| 176 | const double G = m_C.Value() / st; |
| 177 | const double I = -G * deltaV(); |
| 178 | 178 | set(G, 0.0, I); |
| 179 | 179 | } |
| 180 | 180 | |
| r242997 | r242998 | |
| 198 | 198 | public: |
| 199 | 199 | ATTR_COLD netlist_generic_diode(); |
| 200 | 200 | |
| 201 | | ATTR_HOT inline void update_diode(const nl_double nVd) |
| 201 | ATTR_HOT inline void update_diode(const double nVd) |
| 202 | 202 | { |
| 203 | 203 | //FIXME: Optimize cutoff case |
| 204 | 204 | |
| r242997 | r242998 | |
| 212 | 212 | { |
| 213 | 213 | m_Vd = nVd; |
| 214 | 214 | |
| 215 | | const nl_double eVDVt = exp(m_Vd * m_VtInv); |
| 215 | const double eVDVt = exp(m_Vd * m_VtInv); |
| 216 | 216 | m_Id = m_Is * (eVDVt - 1.0); |
| 217 | 217 | m_G = m_Is * m_VtInv * eVDVt + m_gmin; |
| 218 | 218 | } |
| r242997 | r242998 | |
| 221 | 221 | #if defined(_MSC_VER) && _MSC_VER < 1800 |
| 222 | 222 | m_Vd = m_Vd + log((nVd - m_Vd) * m_VtInv + 1.0) * m_Vt; |
| 223 | 223 | #else |
| 224 | | nl_double a = (nVd - m_Vd) * m_VtInv; |
| 224 | double a = (nVd - m_Vd) * m_VtInv; |
| 225 | 225 | if (a<1e-12 - 1.0) a = 1e-12 - 1.0; |
| 226 | 226 | m_Vd = m_Vd + log1p(a) * m_Vt; |
| 227 | 227 | #endif |
| 228 | | const nl_double eVDVt = exp(m_Vd * m_VtInv); |
| 228 | const double eVDVt = exp(m_Vd * m_VtInv); |
| 229 | 229 | m_Id = m_Is * (eVDVt - 1.0); |
| 230 | 230 | |
| 231 | 231 | m_G = m_Is * m_VtInv * eVDVt + m_gmin; |
| r242997 | r242998 | |
| 234 | 234 | //printf("nVd %f m_Vd %f Vcrit %f\n", nVd, m_Vd, m_Vcrit); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | | ATTR_COLD void set_param(const nl_double Is, const nl_double n, nl_double gmin); |
| 237 | ATTR_COLD void set_param(const double Is, const double n, double gmin); |
| 238 | 238 | |
| 239 | | ATTR_HOT inline nl_double I() const { return m_Id; } |
| 240 | | ATTR_HOT inline nl_double G() const { return m_G; } |
| 241 | | ATTR_HOT inline nl_double Ieq() const { return (m_Id - m_Vd * m_G); } |
| 242 | | ATTR_HOT inline nl_double Vd() const { return m_Vd; } |
| 239 | ATTR_HOT inline double I() const { return m_Id; } |
| 240 | ATTR_HOT inline double G() const { return m_G; } |
| 241 | ATTR_HOT inline double Ieq() const { return (m_Id - m_Vd * m_G); } |
| 242 | ATTR_HOT inline double Vd() const { return m_Vd; } |
| 243 | 243 | |
| 244 | 244 | /* owning object must save those ... */ |
| 245 | 245 | |
| 246 | 246 | ATTR_COLD void save(pstring name, netlist_object_t &parent); |
| 247 | 247 | |
| 248 | 248 | private: |
| 249 | | nl_double m_Vd; |
| 250 | | nl_double m_Id; |
| 251 | | nl_double m_G; |
| 249 | double m_Vd; |
| 250 | double m_Id; |
| 251 | double m_G; |
| 252 | 252 | |
| 253 | | nl_double m_Vt; |
| 254 | | nl_double m_Is; |
| 255 | | nl_double m_n; |
| 256 | | nl_double m_gmin; |
| 253 | double m_Vt; |
| 254 | double m_Is; |
| 255 | double m_n; |
| 256 | double m_gmin; |
| 257 | 257 | |
| 258 | | nl_double m_VtInv; |
| 259 | | nl_double m_Vcrit; |
| 258 | double m_VtInv; |
| 259 | double m_Vcrit; |
| 260 | 260 | }; |
| 261 | 261 | |
| 262 | 262 | // ---------------------------------------------------------------------------------------- |
| r242997 | r242998 | |
| 268 | 268 | // add c3 and it'll be better than 1% |
| 269 | 269 | |
| 270 | 270 | #if 0 |
| 271 | | inline nl_double fastexp_h(const nl_double x) |
| 271 | inline double fastexp_h(const double x) |
| 272 | 272 | { |
| 273 | | static const nl_double ln2r = 1.442695040888963387; |
| 274 | | static const nl_double ln2 = 0.693147180559945286; |
| 275 | | //static const nl_double c3 = 0.166666666666666667; |
| 273 | static const double ln2r = 1.442695040888963387; |
| 274 | static const double ln2 = 0.693147180559945286; |
| 275 | //static const double c3 = 0.166666666666666667; |
| 276 | 276 | |
| 277 | | const nl_double y = x * ln2r; |
| 277 | const double y = x * ln2r; |
| 278 | 278 | const unsigned int t = y; |
| 279 | | const nl_double z = (x - ln2 * (double) t); |
| 280 | | const nl_double zz = z * z; |
| 281 | | //const nl_double zzz = zz * z; |
| 279 | const double z = (x - ln2 * (double) t); |
| 280 | const double zz = z * z; |
| 281 | //const double zzz = zz * z; |
| 282 | 282 | |
| 283 | 283 | return (double)(1 << t)*(1.0 + z + 0.5 * zz); // + c3*zzz; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | | inline nl_double fastexp(const nl_double x) |
| 286 | inline double fastexp(const double x) |
| 287 | 287 | { |
| 288 | 288 | if (x<0) |
| 289 | 289 | return 1.0 / fastexp_h(-x); |
trunk/src/emu/netlist/nl_base.c
| r242997 | r242998 | |
| 170 | 170 | netlist_object_t::save_register(); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | | ATTR_HOT const nl_double netlist_base_t::gmin() const |
| 173 | ATTR_HOT const double netlist_base_t::gmin() const |
| 174 | 174 | { |
| 175 | 175 | return solver()->gmin(); |
| 176 | 176 | } |
| r242997 | r242998 | |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | template ATTR_COLD void netlist_device_t::register_param(const pstring &sname, netlist_param_double_t ¶m, const double initialVal); |
| 455 | | template ATTR_COLD void netlist_device_t::register_param(const pstring &sname, netlist_param_double_t ¶m, const float initialVal); |
| 456 | 455 | template ATTR_COLD void netlist_device_t::register_param(const pstring &sname, netlist_param_int_t ¶m, const int initialVal); |
| 457 | 456 | template ATTR_COLD void netlist_device_t::register_param(const pstring &sname, netlist_param_logic_t ¶m, const int initialVal); |
| 458 | 457 | template ATTR_COLD void netlist_device_t::register_param(const pstring &sname, netlist_param_str_t ¶m, const char * const initialVal); |
| r242997 | r242998 | |
| 875 | 874 | net().as_analog().m_cur_Analog = 0.98; |
| 876 | 875 | } |
| 877 | 876 | |
| 878 | | ATTR_COLD void netlist_analog_output_t::initial(const nl_double val) |
| 877 | ATTR_COLD void netlist_analog_output_t::initial(const double val) |
| 879 | 878 | { |
| 880 | 879 | net().as_analog().m_cur_Analog = val * 0.99; |
| 881 | 880 | } |
| r242997 | r242998 | |
| 932 | 931 | } |
| 933 | 932 | |
| 934 | 933 | |
| 935 | | ATTR_COLD nl_double netlist_param_model_t::model_value(const pstring &entity, const nl_double defval) const |
| 934 | ATTR_COLD double netlist_param_model_t::model_value(const pstring &entity, const double defval) const |
| 936 | 935 | { |
| 937 | 936 | pstring tmp = this->Value(); |
| 938 | 937 | // .model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon) |
| r242997 | r242998 | |
| 946 | 945 | if (pequal < 0) |
| 947 | 946 | netlist().error("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr()); |
| 948 | 947 | tmp = tmp.substr(pequal+1); |
| 949 | | nl_double factor = 1.0; |
| 948 | double factor = 1.0; |
| 950 | 949 | switch (*(tmp.right(1).cstr())) |
| 951 | 950 | { |
| 952 | 951 | case 'm': factor = 1e-3; break; |
| r242997 | r242998 | |
| 1002 | 1001 | net.set_time(netlist().time() + m_inc); |
| 1003 | 1002 | } |
| 1004 | 1003 | |
| 1004 | // ---------------------------------------------------------------------------------------- |
| 1005 | // net_device_t_base_factory |
| 1006 | // ---------------------------------------------------------------------------------------- |
| 1007 | |
| 1008 | ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::term_param_list() |
| 1009 | { |
| 1010 | if (m_def_param.startsWith("+")) |
| 1011 | return nl_util::split(m_def_param.substr(1), ","); |
| 1012 | else |
| 1013 | return nl_util::pstring_list(); |
| 1014 | } |
| 1015 | |
| 1016 | ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::def_params() |
| 1017 | { |
| 1018 | if (m_def_param.startsWith("+") || m_def_param.equals("-")) |
| 1019 | return nl_util::pstring_list(); |
| 1020 | else |
| 1021 | return nl_util::split(m_def_param, ","); |
| 1022 | } |
trunk/src/emu/netlist/nl_base.h
| r242997 | r242998 | |
| 272 | 272 | |
| 273 | 273 | struct netlist_logic_family_desc_t |
| 274 | 274 | { |
| 275 | | nl_double m_low_thresh_V; |
| 276 | | nl_double m_high_thresh_V; |
| 277 | | nl_double m_low_V; |
| 278 | | nl_double m_high_V; |
| 279 | | nl_double m_R_low; |
| 280 | | nl_double m_R_high; |
| 275 | double m_low_thresh_V; |
| 276 | double m_high_thresh_V; |
| 277 | double m_low_V; |
| 278 | double m_high_V; |
| 279 | double m_R_low; |
| 280 | double m_R_high; |
| 281 | 281 | }; |
| 282 | 282 | |
| 283 | 283 | /* Terminals inherit the family description from the netlist_device |
| r242997 | r242998 | |
| 474 | 474 | |
| 475 | 475 | ATTR_COLD netlist_terminal_t(); |
| 476 | 476 | |
| 477 | | nl_double *m_Idr1; // drive current |
| 478 | | nl_double *m_go1; // conductance for Voltage from other term |
| 479 | | nl_double *m_gt1; // conductance for total conductance |
| 477 | double *m_Idr1; // drive current |
| 478 | double *m_go1; // conductance for Voltage from other term |
| 479 | double *m_gt1; // conductance for total conductance |
| 480 | 480 | |
| 481 | | ATTR_HOT inline void set(const nl_double G) |
| 481 | ATTR_HOT inline void set(const double G) |
| 482 | 482 | { |
| 483 | 483 | set_ptr(m_Idr1, 0); |
| 484 | 484 | set_ptr(m_go1, G); |
| 485 | 485 | set_ptr(m_gt1, G); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | | ATTR_HOT inline void set(const nl_double GO, const nl_double GT) |
| 488 | ATTR_HOT inline void set(const double GO, const double GT) |
| 489 | 489 | { |
| 490 | 490 | set_ptr(m_Idr1, 0); |
| 491 | 491 | set_ptr(m_go1, GO); |
| 492 | 492 | set_ptr(m_gt1, GT); |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | | ATTR_HOT inline void set(const nl_double GO, const nl_double GT, const nl_double I) |
| 495 | ATTR_HOT inline void set(const double GO, const double GT, const double I) |
| 496 | 496 | { |
| 497 | 497 | set_ptr(m_Idr1, I); |
| 498 | 498 | set_ptr(m_go1, GO); |
| r242997 | r242998 | |
| 509 | 509 | |
| 510 | 510 | ATTR_COLD virtual void reset(); |
| 511 | 511 | private: |
| 512 | | inline void set_ptr(nl_double *ptr, const nl_double val) |
| 512 | inline void set_ptr(double *ptr, const double val) |
| 513 | 513 | { |
| 514 | 514 | if (ptr != NULL) |
| 515 | 515 | *ptr = val; |
| r242997 | r242998 | |
| 586 | 586 | ATTR_COLD netlist_analog_input_t() |
| 587 | 587 | : netlist_input_t(INPUT, ANALOG) { } |
| 588 | 588 | |
| 589 | | ATTR_HOT inline const nl_double Q_Analog() const; |
| 589 | ATTR_HOT inline const double Q_Analog() const; |
| 590 | 590 | }; |
| 591 | 591 | |
| 592 | 592 | //#define INPVAL(_x) (_x).Q() |
| r242997 | r242998 | |
| 661 | 661 | // We have to have those on one object. Dividing those does lead |
| 662 | 662 | // to a significant performance hit |
| 663 | 663 | // FIXME: Have to fix the public at some time |
| 664 | | nl_double m_cur_Analog; |
| 664 | double m_cur_Analog; |
| 665 | 665 | |
| 666 | 666 | }; |
| 667 | 667 | |
| r242997 | r242998 | |
| 736 | 736 | ATTR_COLD netlist_analog_net_t(); |
| 737 | 737 | ATTR_COLD virtual ~netlist_analog_net_t() { }; |
| 738 | 738 | |
| 739 | | ATTR_HOT inline const nl_double Q_Analog() const |
| 739 | ATTR_HOT inline const double Q_Analog() const |
| 740 | 740 | { |
| 741 | 741 | //nl_assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 742 | 742 | nl_assert(family() == ANALOG); |
| 743 | 743 | return m_cur_Analog; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | | ATTR_COLD inline nl_double &Q_Analog_state_ptr() |
| 746 | ATTR_COLD inline double &Q_Analog_state_ptr() |
| 747 | 747 | { |
| 748 | 748 | //nl_assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 749 | 749 | nl_assert(family() == ANALOG); |
| r242997 | r242998 | |
| 764 | 764 | private: |
| 765 | 765 | |
| 766 | 766 | public: |
| 767 | | nl_double m_DD_n_m_1; |
| 768 | | nl_double m_h_n_m_1; |
| 767 | double m_DD_n_m_1; |
| 768 | double m_h_n_m_1; |
| 769 | 769 | |
| 770 | 770 | //FIXME: needed by current solver code |
| 771 | 771 | netlist_matrix_solver_t *m_solver; |
| r242997 | r242998 | |
| 831 | 831 | |
| 832 | 832 | ATTR_COLD netlist_analog_output_t(); |
| 833 | 833 | |
| 834 | | ATTR_COLD void initial(const nl_double val); |
| 834 | ATTR_COLD void initial(const double val); |
| 835 | 835 | |
| 836 | | ATTR_HOT inline void set_Q(const nl_double newQ); |
| 836 | ATTR_HOT inline void set_Q(const double newQ); |
| 837 | 837 | |
| 838 | 838 | netlist_analog_net_t *m_proxied_net; // only for proxy nets in analog input logic |
| 839 | 839 | |
| r242997 | r242998 | |
| 876 | 876 | public: |
| 877 | 877 | ATTR_COLD netlist_param_double_t(); |
| 878 | 878 | |
| 879 | | ATTR_HOT inline void setTo(const nl_double param); |
| 880 | | ATTR_COLD inline void initial(const nl_double val) { m_param = val; } |
| 881 | | ATTR_HOT inline const nl_double Value() const { return m_param; } |
| 879 | ATTR_HOT inline void setTo(const double param); |
| 880 | ATTR_COLD inline void initial(const double val) { m_param = val; } |
| 881 | ATTR_HOT inline const double Value() const { return m_param; } |
| 882 | 882 | |
| 883 | 883 | protected: |
| 884 | 884 | ATTR_COLD virtual void save_register() |
| r242997 | r242998 | |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | private: |
| 891 | | nl_double m_param; |
| 891 | double m_param; |
| 892 | 892 | }; |
| 893 | 893 | |
| 894 | 894 | class netlist_param_int_t : public netlist_param_t |
| r242997 | r242998 | |
| 946 | 946 | ATTR_HOT inline const pstring &Value() const { return m_param; } |
| 947 | 947 | |
| 948 | 948 | /* these should be cached! */ |
| 949 | | ATTR_COLD nl_double model_value(const pstring &entity, const nl_double defval = 0.0) const; |
| 949 | ATTR_COLD double model_value(const pstring &entity, const double defval = 0.0) const; |
| 950 | 950 | ATTR_COLD const pstring model_type() const; |
| 951 | 951 | |
| 952 | 952 | private: |
| r242997 | r242998 | |
| 997 | 997 | out.set_Q(val, delay); |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | | ATTR_HOT inline const nl_double INPANALOG(const netlist_analog_input_t &inp) const { return inp.Q_Analog(); } |
| 1000 | ATTR_HOT inline const double INPANALOG(const netlist_analog_input_t &inp) const { return inp.Q_Analog(); } |
| 1001 | 1001 | |
| 1002 | | ATTR_HOT inline const nl_double TERMANALOG(const netlist_terminal_t &term) const { return term.net().as_analog().Q_Analog(); } |
| 1002 | ATTR_HOT inline const double TERMANALOG(const netlist_terminal_t &term) const { return term.net().as_analog().Q_Analog(); } |
| 1003 | 1003 | |
| 1004 | | ATTR_HOT inline void OUTANALOG(netlist_analog_output_t &out, const nl_double val) |
| 1004 | ATTR_HOT inline void OUTANALOG(netlist_analog_output_t &out, const double val) |
| 1005 | 1005 | { |
| 1006 | 1006 | out.set_Q(val); |
| 1007 | 1007 | } |
| r242997 | r242998 | |
| 1010 | 1010 | |
| 1011 | 1011 | ATTR_HOT virtual void dec_active() { } |
| 1012 | 1012 | |
| 1013 | | ATTR_HOT virtual void step_time(const nl_double st) { } |
| 1013 | ATTR_HOT virtual void step_time(const double st) { } |
| 1014 | 1014 | ATTR_HOT virtual void update_terminals() { } |
| 1015 | 1015 | |
| 1016 | 1016 | |
| r242997 | r242998 | |
| 1120 | 1120 | ATTR_HOT inline const netlist_time time() const { return m_time; } |
| 1121 | 1121 | ATTR_HOT inline NETLIB_NAME(solver) *solver() const { return m_solver; } |
| 1122 | 1122 | ATTR_HOT inline NETLIB_NAME(gnd) *gnd() const { return m_gnd; } |
| 1123 | | ATTR_HOT const nl_double gmin() const; |
| 1123 | ATTR_HOT const double gmin() const; |
| 1124 | 1124 | |
| 1125 | 1125 | ATTR_HOT inline void push_to_queue(netlist_net_t *out, const netlist_time attime) |
| 1126 | 1126 | { |
| r242997 | r242998 | |
| 1251 | 1251 | } |
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | | ATTR_HOT inline void netlist_param_double_t::setTo(const nl_double param) |
| 1254 | ATTR_HOT inline void netlist_param_double_t::setTo(const double param) |
| 1255 | 1255 | { |
| 1256 | 1256 | if (m_param != param) |
| 1257 | 1257 | { |
| r242997 | r242998 | |
| 1356 | 1356 | return net().as_logic().Q(); |
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | | ATTR_HOT inline const nl_double netlist_analog_input_t::Q_Analog() const |
| 1359 | ATTR_HOT inline const double netlist_analog_input_t::Q_Analog() const |
| 1360 | 1360 | { |
| 1361 | 1361 | return net().as_analog().Q_Analog(); |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | | ATTR_HOT inline void netlist_analog_output_t::set_Q(const nl_double newQ) |
| 1364 | ATTR_HOT inline void netlist_analog_output_t::set_Q(const double newQ) |
| 1365 | 1365 | { |
| 1366 | 1366 | if (newQ != net().as_analog().m_cur_Analog) |
| 1367 | 1367 | { |
trunk/src/emu/netlist/nl_setup.h
| r242997 | r242998 | |
| 3 | 3 | /* |
| 4 | 4 | * nlsetup.h |
| 5 | 5 | * |
| 6 | * Created on: 3 Nov 2013 |
| 7 | * Author: andre |
| 6 | 8 | */ |
| 7 | 9 | |
| 8 | 10 | #ifndef NLSETUP_H_ |
| 9 | 11 | #define NLSETUP_H_ |
| 10 | 12 | |
| 11 | 13 | #include "nl_base.h" |
| 12 | | //#include "nl_factory.h" |
| 14 | #include "nl_factory.h" |
| 13 | 15 | |
| 14 | 16 | //============================================================ |
| 15 | 17 | // MACROS / inline netlist definitions |
| r242997 | r242998 | |
| 23 | 25 | #define ALIAS(_alias, _name) \ |
| 24 | 26 | setup.register_alias(# _alias, # _name); |
| 25 | 27 | |
| 26 | | //#define NET_NEW(_type) setup.factory().new_device_by_classname(NETLIB_NAME_STR(_type), setup) |
| 28 | #define NET_NEW(_type) setup.factory().new_device_by_classname(NETLIB_NAME_STR(_type), setup) |
| 27 | 29 | |
| 28 | 30 | #define NET_REGISTER_DEV(_type, _name) \ |
| 29 | | setup.register_dev(NETLIB_NAME_STR(_type), # _name); |
| 31 | setup.register_dev(NET_NEW(_type), # _name); |
| 30 | 32 | |
| 31 | 33 | #define NET_REMOVE_DEV(_name) \ |
| 32 | 34 | setup.remove_dev(# _name); |
| r242997 | r242998 | |
| 65 | 67 | setup.namespace_pop(); |
| 66 | 68 | |
| 67 | 69 | // ---------------------------------------------------------------------------------------- |
| 70 | // FIXME: Clean this up |
| 71 | // ---------------------------------------------------------------------------------------- |
| 72 | |
| 73 | //class NETLIB_NAME(analog_callback); |
| 74 | |
| 75 | // ---------------------------------------------------------------------------------------- |
| 68 | 76 | // netlist_setup_t |
| 69 | 77 | // ---------------------------------------------------------------------------------------- |
| 70 | 78 | |
| 71 | | // Forward definition so we keep nl_factory.h out of the public |
| 72 | | class netlist_factory_t; |
| 73 | | |
| 74 | 79 | class netlist_setup_t |
| 75 | 80 | { |
| 76 | 81 | NETLIST_PREVENT_COPYING(netlist_setup_t) |
| r242997 | r242998 | |
| 113 | 118 | |
| 114 | 119 | netlist_base_t &netlist() { return m_netlist; } |
| 115 | 120 | const netlist_base_t &netlist() const { return m_netlist; } |
| 121 | netlist_factory_t &factory() { return m_factory; } |
| 122 | const netlist_factory_t &factory() const { return m_factory; } |
| 116 | 123 | |
| 117 | 124 | pstring build_fqn(const pstring &obj_name) const; |
| 118 | 125 | |
| 119 | 126 | netlist_device_t *register_dev(netlist_device_t *dev, const pstring &name); |
| 120 | | netlist_device_t *register_dev(const pstring &classname, const pstring &name); |
| 121 | 127 | void remove_dev(const pstring &name); |
| 122 | 128 | |
| 123 | 129 | void register_model(const pstring &model); |
| r242997 | r242998 | |
| 146 | 152 | void namespace_push(const pstring &aname); |
| 147 | 153 | void namespace_pop(); |
| 148 | 154 | |
| 149 | | netlist_factory_t &factory() { return *m_factory; } |
| 150 | | const netlist_factory_t &factory() const { return *m_factory; } |
| 155 | /* not ideal, but needed for save_state */ |
| 156 | tagmap_terminal_t m_terminals; |
| 151 | 157 | |
| 152 | | /* not ideal, but needed for save_state */ |
| 153 | | tagmap_terminal_t m_terminals; |
| 158 | void print_stats() const; |
| 154 | 159 | |
| 155 | | void print_stats() const; |
| 156 | | |
| 157 | 160 | protected: |
| 158 | 161 | |
| 159 | 162 | private: |
| r242997 | r242998 | |
| 165 | 168 | tagmap_link_t m_links; |
| 166 | 169 | tagmap_nstring_t m_params_temp; |
| 167 | 170 | |
| 168 | | netlist_factory_t *m_factory; |
| 171 | netlist_factory_t m_factory; |
| 169 | 172 | |
| 170 | 173 | plinearlist_t<pstring> m_models; |
| 171 | 174 | |
trunk/src/mess/drivers/ngen.c
| r242997 | r242998 | |
| 67 | 67 | #include "machine/pit8253.h" |
| 68 | 68 | #include "machine/z80dart.h" |
| 69 | 69 | #include "machine/wd_fdc.h" |
| 70 | | #include "machine/wd2010.h" |
| 71 | 70 | #include "bus/rs232/rs232.h" |
| 72 | 71 | #include "machine/ngen_kb.h" |
| 73 | 72 | #include "machine/clock.h" |
| 74 | | #include "imagedev/harddriv.h" |
| 75 | 73 | |
| 76 | 74 | class ngen_state : public driver_device |
| 77 | 75 | { |
| r242997 | r242998 | |
| 91 | 89 | m_fdc(*this,"fdc"), |
| 92 | 90 | m_fd0(*this,"fdc:0"), |
| 93 | 91 | m_fdc_timer(*this,"fdc_timer"), |
| 94 | | m_hdc(*this,"hdc"), |
| 95 | | m_hdc_timer(*this,"hdc_timer"), |
| 96 | | m_hd_buffer(*this,"hd_buffer_ram") |
| 92 | m_hdc_timer(*this,"hdc_timer") |
| 97 | 93 | {} |
| 98 | 94 | |
| 99 | 95 | DECLARE_WRITE_LINE_MEMBER(pit_out0_w); |
| r242997 | r242998 | |
| 133 | 129 | DECLARE_READ8_MEMBER(irq_cb); |
| 134 | 130 | DECLARE_WRITE8_MEMBER(hdc_control_w); |
| 135 | 131 | DECLARE_WRITE8_MEMBER(disk_addr_ext); |
| 136 | | DECLARE_READ8_MEMBER(hd_buffer_r); |
| 137 | | DECLARE_WRITE8_MEMBER(hd_buffer_w); |
| 138 | 132 | |
| 139 | 133 | protected: |
| 140 | 134 | virtual void machine_reset(); |
| 141 | | virtual void machine_start(); |
| 142 | 135 | |
| 143 | 136 | private: |
| 144 | 137 | required_device<i80186_cpu_device> m_maincpu; |
| r242997 | r242998 | |
| 154 | 147 | optional_device<wd2797_t> m_fdc; |
| 155 | 148 | optional_device<floppy_connector> m_fd0; |
| 156 | 149 | optional_device<pit8253_device> m_fdc_timer; |
| 157 | | optional_device<wd2010_device> m_hdc; |
| 158 | 150 | optional_device<pit8253_device> m_hdc_timer; |
| 159 | | optional_shared_ptr<UINT8> m_hd_buffer; |
| 160 | 151 | |
| 161 | 152 | void set_dma_channel(int channel, int state); |
| 162 | 153 | |
| r242997 | r242998 | |
| 479 | 470 | case 0x0a: |
| 480 | 471 | case 0x0b: |
| 481 | 472 | if(mem_mask & 0x00ff) |
| 482 | | m_fdc_timer->write(space,offset-0x08,data & 0xff); |
| 473 | m_fdc_timer->write(space,offset,data & 0xff); |
| 483 | 474 | break; |
| 484 | 475 | case 0x10: |
| 485 | 476 | case 0x11: |
| r242997 | r242998 | |
| 489 | 480 | case 0x15: |
| 490 | 481 | case 0x16: |
| 491 | 482 | case 0x17: |
| 492 | | if(mem_mask & 0x00ff) |
| 493 | | m_hdc->write(space,offset-0x10,data & 0xff); |
| 494 | 483 | logerror("WD1010 register %i write %02x mask %04x\n",offset-0x10,data & 0xff,mem_mask); |
| 495 | 484 | break; |
| 496 | 485 | case 0x18: |
| r242997 | r242998 | |
| 498 | 487 | case 0x1a: |
| 499 | 488 | case 0x1b: |
| 500 | 489 | if(mem_mask & 0x00ff) |
| 501 | | m_hdc_timer->write(space,offset-0x18,data & 0xff); |
| 490 | m_hdc_timer->write(space,offset,data & 0xff); |
| 502 | 491 | break; |
| 503 | 492 | } |
| 504 | 493 | } |
| r242997 | r242998 | |
| 521 | 510 | case 0x0a: |
| 522 | 511 | case 0x0b: |
| 523 | 512 | if(mem_mask & 0x00ff) |
| 524 | | ret = m_fdc_timer->read(space,offset-0x08); |
| 513 | ret = m_fdc_timer->read(space,offset); |
| 525 | 514 | break; |
| 526 | 515 | case 0x10: |
| 527 | 516 | case 0x11: |
| r242997 | r242998 | |
| 531 | 520 | case 0x15: |
| 532 | 521 | case 0x16: |
| 533 | 522 | case 0x17: |
| 534 | | if(mem_mask & 0x00ff) |
| 535 | | ret = m_hdc->read(space,offset-0x10); |
| 536 | 523 | logerror("WD1010 register %i read, mask %04x\n",offset-0x10,mem_mask); |
| 537 | 524 | break; |
| 538 | 525 | case 0x18: |
| r242997 | r242998 | |
| 540 | 527 | case 0x1a: |
| 541 | 528 | case 0x1b: |
| 542 | 529 | if(mem_mask & 0x00ff) |
| 543 | | ret = m_hdc_timer->read(space,offset-0x18); |
| 530 | ret = m_hdc_timer->read(space,offset); |
| 544 | 531 | break; |
| 545 | 532 | } |
| 546 | 533 | |
| r242997 | r242998 | |
| 598 | 585 | m_disk_page = data & 0x7f; |
| 599 | 586 | } |
| 600 | 587 | |
| 601 | | READ8_MEMBER(ngen_state::hd_buffer_r) |
| 602 | | { |
| 603 | | return m_hd_buffer[offset]; |
| 604 | | } |
| 605 | | |
| 606 | | WRITE8_MEMBER(ngen_state::hd_buffer_w) |
| 607 | | { |
| 608 | | m_hd_buffer[offset] = data; |
| 609 | | } |
| 610 | | |
| 611 | 588 | WRITE_LINE_MEMBER( ngen_state::dma_hrq_changed ) |
| 612 | 589 | { |
| 613 | 590 | m_maincpu->set_input_line(INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE); |
| r242997 | r242998 | |
| 626 | 603 | { |
| 627 | 604 | if(state) |
| 628 | 605 | { |
| 629 | | if(m_hdc_control & 0x04) // ROM transfer |
| 606 | if(m_hdc_control & 0x04) // ROM transfer? |
| 630 | 607 | m_hdc_control &= ~0x04; // switch it off when done |
| 631 | 608 | } |
| 632 | 609 | } |
| r242997 | r242998 | |
| 712 | 689 | return m_pic->acknowledge(); |
| 713 | 690 | } |
| 714 | 691 | |
| 715 | | void ngen_state::machine_start() |
| 716 | | { |
| 717 | | m_hd_buffer.allocate(1024*8); // 8kB buffer RAM for HD controller |
| 718 | | } |
| 719 | | |
| 720 | 692 | void ngen_state::machine_reset() |
| 721 | 693 | { |
| 722 | 694 | m_port00 = 0; |
| r242997 | r242998 | |
| 865 | 837 | MCFG_WD_FDC_DRQ_CALLBACK(DEVWRITELINE("maincpu",i80186_cpu_device,drq1_w)) |
| 866 | 838 | MCFG_WD_FDC_FORCE_READY |
| 867 | 839 | MCFG_DEVICE_ADD("fdc_timer", PIT8253, 0) |
| 868 | | MCFG_PIT8253_CLK0(XTAL_20MHz / 20) |
| 869 | | MCFG_PIT8253_OUT0_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) // clocked on FDC data register access |
| 840 | MCFG_PIT8253_CLK0(XTAL_20MHz / 20) |
| 841 | MCFG_PIT8253_OUT0_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) |
| 870 | 842 | MCFG_PIT8253_CLK1(XTAL_20MHz / 20) |
| 871 | | MCFG_PIT8253_OUT1_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) // 1MHz |
| 872 | | MCFG_PIT8253_CLK2(XTAL_20MHz / 10) |
| 873 | | MCFG_PIT8253_OUT2_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) |
| 874 | | // TODO: WD1010 HDC (not implemented), use WD2010 for now |
| 875 | | MCFG_DEVICE_ADD("hdc", WD2010, XTAL_20MHz / 4) |
| 876 | | MCFG_WD2010_IN_BCS_CB(READ8(ngen_state,hd_buffer_r)) |
| 877 | | MCFG_WD2010_OUT_BCS_CB(WRITE8(ngen_state,hd_buffer_w)) |
| 878 | | MCFG_WD2010_IN_DRDY_CB(VCC) |
| 879 | | MCFG_WD2010_IN_INDEX_CB(VCC) |
| 880 | | MCFG_WD2010_IN_WF_CB(VCC) |
| 881 | | MCFG_WD2010_IN_TK000_CB(VCC) |
| 882 | | MCFG_WD2010_IN_SC_CB(VCC) |
| 843 | MCFG_PIT8253_OUT1_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) |
| 844 | MCFG_PIT8253_CLK2(XTAL_20MHz / 20) |
| 845 | MCFG_PIT8253_OUT2_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) |
| 846 | // TODO: WD1010 HDC (not implemented) |
| 883 | 847 | MCFG_DEVICE_ADD("hdc_timer", PIT8253, 0) |
| 884 | | MCFG_PIT8253_CLK2(XTAL_20MHz / 10) // 2MHz |
| 885 | 848 | MCFG_FLOPPY_DRIVE_ADD("fdc:0", ngen_floppies, "525qd", floppy_image_device::default_floppy_formats) |
| 886 | | MCFG_HARDDISK_ADD("hard0") |
| 887 | 849 | |
| 888 | 850 | MACHINE_CONFIG_END |
| 889 | 851 | |
trunk/src/mess/drivers/splitsec.c
| r242997 | r242998 | |
| 4 | 4 | |
| 5 | 5 | Parker Brothers Split Second |
| 6 | 6 | * TMS1400NLL MP7314-N2 (die labeled MP7314) |
| 7 | | |
| 8 | | This is an electronic handheld reflex gaming device, it's straightforward |
| 9 | | to use. The included mini-games are: |
| 10 | | 1, 2, 3: Mad Maze* |
| 11 | | 4, 5: Space Attack* |
| 12 | | 6: Auto Cross |
| 13 | | 7: Stomp |
| 14 | | 8: Speedball |
| 15 | | |
| 16 | | *: higher number indicates harder difficulty |
| 17 | 7 | |
| 18 | 8 | |
| 19 | | TODO: |
| 20 | | - MCU clock is unknown |
| 21 | | |
| 22 | 9 | ***************************************************************************/ |
| 23 | 10 | |
| 24 | 11 | #include "emu.h" |
| r242997 | r242998 | |
| 27 | 14 | |
| 28 | 15 | #include "splitsec.lh" |
| 29 | 16 | |
| 30 | | // The master clock is a single stage RC oscillator: R=24K, C=100pf, |
| 31 | | // according to the TMS 1000 series data manual this is around 375kHz. |
| 32 | | // However, this sounds too low-pitched and runs too slow when compared |
| 33 | | // to recordings, maybe the RC osc curve is different for TMS1400? |
| 17 | // master clock is a single stage RC oscillator: R=24K, C=100pf, |
| 18 | // according to the TMS 1000 series data manual this is around 375kHz |
| 19 | #define MASTER_CLOCK (375000) |
| 34 | 20 | |
| 35 | | // so for now, the value below is an approximation |
| 36 | | #define MASTER_CLOCK (485000) |
| 37 | 21 | |
| 38 | | |
| 39 | 22 | class splitsec_state : public driver_device |
| 40 | 23 | { |
| 41 | 24 | public: |
| r242997 | r242998 | |
| 177 | 160 | |
| 178 | 161 | static INPUT_PORTS_START( splitsec ) |
| 179 | 162 | PORT_START("IN.0") // R9 |
| 180 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_16WAY |
| 181 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_16WAY |
| 182 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_16WAY |
| 163 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) |
| 164 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) |
| 165 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) |
| 183 | 166 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 184 | 167 | |
| 185 | 168 | PORT_START("IN.1") // R10 |
| 186 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_16WAY |
| 169 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) |
| 187 | 170 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Select") |
| 188 | 171 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Start") |
| 189 | 172 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| r242997 | r242998 | |
| 247 | 230 | |
| 248 | 231 | ROM_START( splitsec ) |
| 249 | 232 | ROM_REGION( 0x1000, "maincpu", 0 ) |
| 250 | | ROM_LOAD( "tms1400nll_mp7314", 0x0000, 0x1000, CRC(e94b2098) SHA1(f0fc1f56a829252185592a2508740354c50bedf8) ) |
| 233 | ROM_LOAD( "tms1400nll_mp7314", 0x0000, 0x1000, CRC(0cccdf59) SHA1(06a533134a433aaf856b80f0ca239d0498b98d5f) ) |
| 251 | 234 | |
| 252 | 235 | ROM_REGION( 867, "maincpu:mpla", 0 ) |
| 253 | 236 | ROM_LOAD( "tms1100_default_mpla.pla", 0, 867, CRC(62445fc9) SHA1(d6297f2a4bc7a870b76cc498d19dbb0ce7d69fec) ) |
| r242997 | r242998 | |
| 256 | 239 | ROM_END |
| 257 | 240 | |
| 258 | 241 | |
| 259 | | CONS( 1980, splitsec, 0, 0, splitsec, splitsec, driver_device, 0, "Parker Brothers", "Split Second", GAME_SUPPORTS_SAVE ) |
| 242 | CONS( 1980, splitsec, 0, 0, splitsec, splitsec, driver_device, 0, "Parker Brothers", "Split Second", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) |
trunk/src/mess/layout/splitsec.lay
| r242997 | r242998 | |
| 25 | 25 | |
| 26 | 26 | <!-- maze of lamps --> |
| 27 | 27 | |
| 28 | | <bezel name="lamp0" element="lamp_rect"><bounds x="2" y="1" width="4" height="1" /></bezel> |
| 29 | | <bezel name="lamp2" element="lamp_rect"><bounds x="7" y="1" width="4" height="1" /></bezel> |
| 30 | | <bezel name="lamp4" element="lamp_rect"><bounds x="12" y="1" width="4" height="1" /></bezel> |
| 28 | <bezel name="lamp6" element="lamp_rect"><bounds x="2" y="1" width="4" height="1" /></bezel> |
| 29 | <bezel name="lamp4" element="lamp_rect"><bounds x="7" y="1" width="4" height="1" /></bezel> |
| 30 | <bezel name="lamp2" element="lamp_rect"><bounds x="12" y="1" width="4" height="1" /></bezel> |
| 31 | 31 | |
| 32 | | <bezel name="lamp10" element="lamp_rect"><bounds x="1" y="2" width="1" height="4" /></bezel> |
| 33 | | <bezel name="lamp1" element="lamp_disk"><bounds x="3" y="3" width="2" height="2" /></bezel> |
| 34 | | <bezel name="lamp12" element="lamp_rect"><bounds x="6" y="2" width="1" height="4" /></bezel> |
| 32 | <bezel name="lamp16" element="lamp_rect"><bounds x="1" y="2" width="1" height="4" /></bezel> |
| 33 | <bezel name="lamp5" element="lamp_disk"><bounds x="3" y="3" width="2" height="2" /></bezel> |
| 34 | <bezel name="lamp14" element="lamp_rect"><bounds x="6" y="2" width="1" height="4" /></bezel> |
| 35 | 35 | <bezel name="lamp3" element="lamp_disk"><bounds x="8" y="3" width="2" height="2" /></bezel> |
| 36 | | <bezel name="lamp14" element="lamp_rect"><bounds x="11" y="2" width="1" height="4" /></bezel> |
| 37 | | <bezel name="lamp5" element="lamp_disk"><bounds x="13" y="3" width="2" height="2" /></bezel> |
| 38 | | <bezel name="lamp16" element="lamp_rect"><bounds x="16" y="2" width="1" height="4" /></bezel> |
| 36 | <bezel name="lamp12" element="lamp_rect"><bounds x="11" y="2" width="1" height="4" /></bezel> |
| 37 | <bezel name="lamp1" element="lamp_disk"><bounds x="13" y="3" width="2" height="2" /></bezel> |
| 38 | <bezel name="lamp10" element="lamp_rect"><bounds x="16" y="2" width="1" height="4" /></bezel> |
| 39 | 39 | |
| 40 | | <bezel name="lamp11" element="lamp_rect"><bounds x="2" y="6" width="4" height="1" /></bezel> |
| 40 | <bezel name="lamp15" element="lamp_rect"><bounds x="2" y="6" width="4" height="1" /></bezel> |
| 41 | 41 | <bezel name="lamp13" element="lamp_rect"><bounds x="7" y="6" width="4" height="1" /></bezel> |
| 42 | | <bezel name="lamp15" element="lamp_rect"><bounds x="12" y="6" width="4" height="1" /></bezel> |
| 42 | <bezel name="lamp11" element="lamp_rect"><bounds x="12" y="6" width="4" height="1" /></bezel> |
| 43 | 43 | |
| 44 | | <bezel name="lamp20" element="lamp_rect"><bounds x="1" y="7" width="1" height="4" /></bezel> |
| 45 | | <bezel name="lamp21" element="lamp_disk"><bounds x="3" y="8" width="2" height="2" /></bezel> |
| 46 | | <bezel name="lamp22" element="lamp_rect"><bounds x="6" y="7" width="1" height="4" /></bezel> |
| 44 | <bezel name="lamp26" element="lamp_rect"><bounds x="1" y="7" width="1" height="4" /></bezel> |
| 45 | <bezel name="lamp25" element="lamp_disk"><bounds x="3" y="8" width="2" height="2" /></bezel> |
| 46 | <bezel name="lamp24" element="lamp_rect"><bounds x="6" y="7" width="1" height="4" /></bezel> |
| 47 | 47 | <bezel name="lamp23" element="lamp_disk"><bounds x="8" y="8" width="2" height="2" /></bezel> |
| 48 | | <bezel name="lamp24" element="lamp_rect"><bounds x="11" y="7" width="1" height="4" /></bezel> |
| 49 | | <bezel name="lamp25" element="lamp_disk"><bounds x="13" y="8" width="2" height="2" /></bezel> |
| 50 | | <bezel name="lamp26" element="lamp_rect"><bounds x="16" y="7" width="1" height="4" /></bezel> |
| 48 | <bezel name="lamp22" element="lamp_rect"><bounds x="11" y="7" width="1" height="4" /></bezel> |
| 49 | <bezel name="lamp21" element="lamp_disk"><bounds x="13" y="8" width="2" height="2" /></bezel> |
| 50 | <bezel name="lamp20" element="lamp_rect"><bounds x="16" y="7" width="1" height="4" /></bezel> |
| 51 | 51 | |
| 52 | | <bezel name="lamp31" element="lamp_rect"><bounds x="2" y="11" width="4" height="1" /></bezel> |
| 52 | <bezel name="lamp35" element="lamp_rect"><bounds x="2" y="11" width="4" height="1" /></bezel> |
| 53 | 53 | <bezel name="lamp33" element="lamp_rect"><bounds x="7" y="11" width="4" height="1" /></bezel> |
| 54 | | <bezel name="lamp35" element="lamp_rect"><bounds x="12" y="11" width="4" height="1" /></bezel> |
| 54 | <bezel name="lamp31" element="lamp_rect"><bounds x="12" y="11" width="4" height="1" /></bezel> |
| 55 | 55 | |
| 56 | | <bezel name="lamp30" element="lamp_rect"><bounds x="1" y="12" width="1" height="4" /></bezel> |
| 57 | | <bezel name="lamp41" element="lamp_disk"><bounds x="3" y="13" width="2" height="2" /></bezel> |
| 58 | | <bezel name="lamp32" element="lamp_rect"><bounds x="6" y="12" width="1" height="4" /></bezel> |
| 56 | <bezel name="lamp36" element="lamp_rect"><bounds x="1" y="12" width="1" height="4" /></bezel> |
| 57 | <bezel name="lamp45" element="lamp_disk"><bounds x="3" y="13" width="2" height="2" /></bezel> |
| 58 | <bezel name="lamp34" element="lamp_rect"><bounds x="6" y="12" width="1" height="4" /></bezel> |
| 59 | 59 | <bezel name="lamp43" element="lamp_disk"><bounds x="8" y="13" width="2" height="2" /></bezel> |
| 60 | | <bezel name="lamp34" element="lamp_rect"><bounds x="11" y="12" width="1" height="4" /></bezel> |
| 61 | | <bezel name="lamp45" element="lamp_disk"><bounds x="13" y="13" width="2" height="2" /></bezel> |
| 62 | | <bezel name="lamp36" element="lamp_rect"><bounds x="16" y="12" width="1" height="4" /></bezel> |
| 60 | <bezel name="lamp32" element="lamp_rect"><bounds x="11" y="12" width="1" height="4" /></bezel> |
| 61 | <bezel name="lamp41" element="lamp_disk"><bounds x="13" y="13" width="2" height="2" /></bezel> |
| 62 | <bezel name="lamp30" element="lamp_rect"><bounds x="16" y="12" width="1" height="4" /></bezel> |
| 63 | 63 | |
| 64 | | <bezel name="lamp51" element="lamp_rect"><bounds x="2" y="16" width="4" height="1" /></bezel> |
| 64 | <bezel name="lamp55" element="lamp_rect"><bounds x="2" y="16" width="4" height="1" /></bezel> |
| 65 | 65 | <bezel name="lamp53" element="lamp_rect"><bounds x="7" y="16" width="4" height="1" /></bezel> |
| 66 | | <bezel name="lamp55" element="lamp_rect"><bounds x="12" y="16" width="4" height="1" /></bezel> |
| 66 | <bezel name="lamp51" element="lamp_rect"><bounds x="12" y="16" width="4" height="1" /></bezel> |
| 67 | 67 | |
| 68 | | <bezel name="lamp40" element="lamp_rect"><bounds x="1" y="17" width="1" height="4" /></bezel> |
| 69 | | <bezel name="lamp61" element="lamp_disk"><bounds x="3" y="18" width="2" height="2" /></bezel> |
| 70 | | <bezel name="lamp42" element="lamp_rect"><bounds x="6" y="17" width="1" height="4" /></bezel> |
| 68 | <bezel name="lamp46" element="lamp_rect"><bounds x="1" y="17" width="1" height="4" /></bezel> |
| 69 | <bezel name="lamp65" element="lamp_disk"><bounds x="3" y="18" width="2" height="2" /></bezel> |
| 70 | <bezel name="lamp44" element="lamp_rect"><bounds x="6" y="17" width="1" height="4" /></bezel> |
| 71 | 71 | <bezel name="lamp63" element="lamp_disk"><bounds x="8" y="18" width="2" height="2" /></bezel> |
| 72 | | <bezel name="lamp44" element="lamp_rect"><bounds x="11" y="17" width="1" height="4" /></bezel> |
| 73 | | <bezel name="lamp65" element="lamp_disk"><bounds x="13" y="18" width="2" height="2" /></bezel> |
| 74 | | <bezel name="lamp46" element="lamp_rect"><bounds x="16" y="17" width="1" height="4" /></bezel> |
| 72 | <bezel name="lamp42" element="lamp_rect"><bounds x="11" y="17" width="1" height="4" /></bezel> |
| 73 | <bezel name="lamp61" element="lamp_disk"><bounds x="13" y="18" width="2" height="2" /></bezel> |
| 74 | <bezel name="lamp40" element="lamp_rect"><bounds x="16" y="17" width="1" height="4" /></bezel> |
| 75 | 75 | |
| 76 | | <bezel name="lamp71" element="lamp_rect"><bounds x="2" y="21" width="4" height="1" /></bezel> |
| 76 | <bezel name="lamp75" element="lamp_rect"><bounds x="2" y="21" width="4" height="1" /></bezel> |
| 77 | 77 | <bezel name="lamp73" element="lamp_rect"><bounds x="7" y="21" width="4" height="1" /></bezel> |
| 78 | | <bezel name="lamp75" element="lamp_rect"><bounds x="12" y="21" width="4" height="1" /></bezel> |
| 78 | <bezel name="lamp71" element="lamp_rect"><bounds x="12" y="21" width="4" height="1" /></bezel> |
| 79 | 79 | |
| 80 | | <bezel name="lamp50" element="lamp_rect"><bounds x="1" y="22" width="1" height="4" /></bezel> |
| 81 | | <bezel name="lamp60" element="lamp_disk"><bounds x="3" y="23" width="2" height="2" /></bezel> |
| 82 | | <bezel name="lamp52" element="lamp_rect"><bounds x="6" y="22" width="1" height="4" /></bezel> |
| 83 | | <bezel name="lamp62" element="lamp_disk"><bounds x="8" y="23" width="2" height="2" /></bezel> |
| 84 | | <bezel name="lamp54" element="lamp_rect"><bounds x="11" y="22" width="1" height="4" /></bezel> |
| 85 | | <bezel name="lamp64" element="lamp_disk"><bounds x="13" y="23" width="2" height="2" /></bezel> |
| 86 | | <bezel name="lamp56" element="lamp_rect"><bounds x="16" y="22" width="1" height="4" /></bezel> |
| 80 | <bezel name="lamp56" element="lamp_rect"><bounds x="1" y="22" width="1" height="4" /></bezel> |
| 81 | <bezel name="lamp66" element="lamp_disk"><bounds x="3" y="23" width="2" height="2" /></bezel> |
| 82 | <bezel name="lamp54" element="lamp_rect"><bounds x="6" y="22" width="1" height="4" /></bezel> |
| 83 | <bezel name="lamp64" element="lamp_disk"><bounds x="8" y="23" width="2" height="2" /></bezel> |
| 84 | <bezel name="lamp52" element="lamp_rect"><bounds x="11" y="22" width="1" height="4" /></bezel> |
| 85 | <bezel name="lamp62" element="lamp_disk"><bounds x="13" y="23" width="2" height="2" /></bezel> |
| 86 | <bezel name="lamp50" element="lamp_rect"><bounds x="16" y="22" width="1" height="4" /></bezel> |
| 87 | 87 | |
| 88 | | <bezel name="lamp70" element="lamp_rect"><bounds x="2" y="26" width="4" height="1" /></bezel> |
| 89 | | <bezel name="lamp72" element="lamp_rect"><bounds x="7" y="26" width="4" height="1" /></bezel> |
| 90 | | <bezel name="lamp74" element="lamp_rect"><bounds x="12" y="26" width="4" height="1" /></bezel> |
| 88 | <bezel name="lamp76" element="lamp_rect"><bounds x="2" y="26" width="4" height="1" /></bezel> |
| 89 | <bezel name="lamp74" element="lamp_rect"><bounds x="7" y="26" width="4" height="1" /></bezel> |
| 90 | <bezel name="lamp72" element="lamp_rect"><bounds x="12" y="26" width="4" height="1" /></bezel> |
| 91 | 91 | |
| 92 | 92 | </view> |
| 93 | 93 | </mamelayout> |
trunk/src/osd/sdl/sdlmain.c
| r242997 | r242998 | |
| 31 | 31 | #include <unistd.h> |
| 32 | 32 | #endif |
| 33 | 33 | |
| 34 | | // only for strconv.h |
| 35 | | #if defined(SDLMAME_WIN32) |
| 36 | | #define WIN32_LEAN_AND_MEAN |
| 37 | | #include <windows.h> |
| 38 | | #endif |
| 39 | | |
| 40 | | |
| 41 | 34 | #ifdef SDLMAME_OS2 |
| 42 | 35 | #define INCL_DOS |
| 43 | 36 | #include <os2.h> |
| r242997 | r242998 | |
| 54 | 47 | #include "emu.h" |
| 55 | 48 | #include "clifront.h" |
| 56 | 49 | #include "emuopts.h" |
| 57 | | #include "strconv.h" |
| 58 | 50 | |
| 59 | 51 | // OSD headers |
| 60 | 52 | #include "video.h" |
| r242997 | r242998 | |
| 1211 | 1203 | return result; |
| 1212 | 1204 | } |
| 1213 | 1205 | |
| 1214 | | osd_font *sdl_osd_interface::font_open(const char *_name, int &height) |
| 1206 | osd_font sdl_osd_interface::font_open(const char *_name, int &height) |
| 1215 | 1207 | { |
| 1216 | 1208 | // accept qualifiers from the name |
| 1217 | 1209 | astring name(_name); |
| r242997 | r242998 | |
| 1236 | 1228 | logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; |
| 1237 | 1229 | |
| 1238 | 1230 | // copy in the face name |
| 1239 | | TCHAR *face = tstring_from_utf8(name); |
| 1240 | | _tcsncpy(logfont.lfFaceName, face, sizeof(logfont.lfFaceName) / sizeof(TCHAR)); |
| 1231 | TCHAR *face = wstring_from_utf8(name); |
| 1232 | wcsncpy(logfont.lfFaceName, face, sizeof(logfont.lfFaceName) / sizeof(TCHAR)); |
| 1241 | 1233 | logfont.lfFaceName[sizeof(logfont.lfFaceName) / sizeof(TCHAR)-1] = 0; |
| 1242 | 1234 | osd_free(face); |
| 1243 | 1235 | |
| 1244 | 1236 | // create the font |
| 1245 | 1237 | height = logfont.lfHeight; |
| 1246 | | osd_font *font = reinterpret_cast<osd_font *>(CreateFontIndirect(&logfont)); |
| 1238 | osd_font font = reinterpret_cast<osd_font>(CreateFontIndirect(&logfont)); |
| 1247 | 1239 | if (font == NULL) |
| 1248 | 1240 | return NULL; |
| 1249 | 1241 | |
| r242997 | r242998 | |
| 1256 | 1248 | DeleteDC(dummyDC); |
| 1257 | 1249 | |
| 1258 | 1250 | // if it doesn't match our request, fail |
| 1259 | | char *utf = utf8_from_tstring(realname); |
| 1251 | char *utf = utf8_from_wstring(realname); |
| 1260 | 1252 | int result = core_stricmp(utf, name); |
| 1261 | 1253 | osd_free(utf); |
| 1262 | 1254 | |
| r242997 | r242998 | |
| 1275 | 1267 | // a given OSD font |
| 1276 | 1268 | //------------------------------------------------- |
| 1277 | 1269 | |
| 1278 | | void sdl_osd_interface::font_close(osd_font *font) |
| 1270 | void sdl_osd_interface::font_close(osd_font font) |
| 1279 | 1271 | { |
| 1280 | 1272 | // delete the font ojbect |
| 1281 | 1273 | if (font != NULL) |
| r242997 | r242998 | |
| 1291 | 1283 | // pixel of a black & white font |
| 1292 | 1284 | //------------------------------------------------- |
| 1293 | 1285 | |
| 1294 | | bool sdl_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 1286 | bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 1295 | 1287 | { |
| 1296 | 1288 | // create a dummy DC to work with |
| 1297 | 1289 | HDC dummyDC = CreateCompatibleDC(NULL); |
| r242997 | r242998 | |
| 1433 | 1425 | // font with the given name |
| 1434 | 1426 | //------------------------------------------------- |
| 1435 | 1427 | |
| 1436 | | osd_font *sdl_osd_interface::font_open(const char *_name, int &height) |
| 1428 | osd_font sdl_osd_interface::font_open(const char *_name, int &height) |
| 1437 | 1429 | { |
| 1438 | | return (osd_font *)NULL; |
| 1430 | return (osd_font)NULL; |
| 1439 | 1431 | } |
| 1440 | 1432 | |
| 1441 | 1433 | //------------------------------------------------- |
| r242997 | r242998 | |
| 1443 | 1435 | // a given OSD font |
| 1444 | 1436 | //------------------------------------------------- |
| 1445 | 1437 | |
| 1446 | | void sdl_osd_interface::font_close(osd_font *font) |
| 1438 | void sdl_osd_interface::font_close(osd_font font) |
| 1447 | 1439 | { |
| 1448 | 1440 | } |
| 1449 | 1441 | |
| r242997 | r242998 | |
| 1455 | 1447 | // pixel of a black & white font |
| 1456 | 1448 | //------------------------------------------------- |
| 1457 | 1449 | |
| 1458 | | bool sdl_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 1450 | bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 1459 | 1451 | { |
| 1460 | 1452 | return false; |
| 1461 | 1453 | } |
trunk/src/tools/nltool.c
| r242997 | r242998 | |
| 18 | 18 | #include "netlist/nl_base.h" |
| 19 | 19 | #include "netlist/nl_setup.h" |
| 20 | 20 | #include "netlist/nl_parser.h" |
| 21 | | #include "netlist/nl_factory.h" |
| 22 | 21 | #include "netlist/nl_util.h" |
| 23 | | #include "netlist/devices/net_lib.h" |
| 24 | 22 | #include "options.h" |
| 25 | 23 | |
| 26 | 24 | /*************************************************************************** |
| 27 | | * MAME COMPATIBILITY ... |
| 28 | | * |
| 29 | | * These are needed if we link without libutil |
| 30 | | ***************************************************************************/ |
| 25 | MAME COMPATIBILITY ... |
| 26 | ***************************************************************************/ |
| 31 | 27 | |
| 32 | 28 | #if 0 |
| 33 | 29 | void ATTR_PRINTF(1,2) osd_printf_warning(const char *format, ...) |
| r242997 | r242998 | |
| 39 | 35 | vprintf(format, argptr); |
| 40 | 36 | va_end(argptr); |
| 41 | 37 | } |
| 38 | #endif |
| 42 | 39 | |
| 43 | 40 | void *malloc_file_line(size_t size, const char *file, int line) |
| 44 | 41 | { |
| r242997 | r242998 | |
| 75 | 72 | src_type.name(), dst_type.name()); |
| 76 | 73 | throw; |
| 77 | 74 | } |
| 78 | | #endif |
| 79 | 75 | |
| 80 | 76 | struct options_entry oplist[] = |
| 81 | 77 | { |
| r242997 | r242998 | |
| 87 | 83 | { NULL } |
| 88 | 84 | }; |
| 89 | 85 | |
| 90 | | NETLIST_START(dummy) |
| 91 | | /* Standard stuff */ |
| 92 | | |
| 93 | | CLOCK(clk, 1000) // 1000 Hz |
| 94 | | SOLVER(Solver, 48000) |
| 95 | | |
| 96 | | NETLIST_END() |
| 97 | | |
| 98 | 86 | /*************************************************************************** |
| 99 | 87 | CORE IMPLEMENTATION |
| 100 | 88 | ***************************************************************************/ |
| r242997 | r242998 | |
| 172 | 160 | nl_util::pstring_list ll = nl_util::split(m_logs, ":"); |
| 173 | 161 | for (int i=0; i < ll.count(); i++) |
| 174 | 162 | { |
| 175 | | pstring name = "log_" + ll[i]; |
| 176 | | netlist_device_t *nc = m_setup->register_dev("nld_log", name); |
| 163 | netlist_device_t *nc = m_setup->factory().new_device_by_classname("nld_log", *m_setup); |
| 164 | pstring name = "log_" + ll[i]; |
| 165 | m_setup->register_dev(nc, name); |
| 177 | 166 | m_setup->register_link(name + ".I", ll[i]); |
| 178 | 167 | } |
| 179 | 168 | } |
| r242997 | r242998 | |
| 241 | 230 | nt.init(); |
| 242 | 231 | const netlist_factory_t::list_t &list = nt.setup().factory().list(); |
| 243 | 232 | |
| 244 | | netlist_sources_t sources; |
| 245 | | |
| 246 | | sources.add(netlist_source_t("dummy", &netlist_dummy)); |
| 247 | | sources.parse(nt.setup(),"dummy"); |
| 248 | | |
| 249 | 233 | nt.setup().start_devices(); |
| 250 | 234 | nt.setup().resolve_inputs(); |
| 251 | 235 | |