branches/kale/src/emu/cpu/tms0980/tms0980.c
| r243832 | r243833 | |
| 69 | 69 | */ |
| 70 | 70 | |
| 71 | 71 | /* Microinstructions */ |
| 72 | | #define M_15TN (1<<0) /* 15 to -ALU */ |
| 73 | | #define M_ATN (1<<1) /* ACC to -ALU */ |
| 74 | | #define M_AUTA (1<<2) /* ALU to ACC */ |
| 75 | | #define M_AUTY (1<<3) /* ALU to Y */ |
| 76 | | #define M_C8 (1<<4) /* CARRY8 to STATUS */ |
| 77 | | #define M_CIN (1<<5) /* Carry In to ALU */ |
| 78 | | #define M_CKM (1<<6) /* CKB to MEM */ |
| 79 | | #define M_CKN (1<<7) /* CKB to -ALU */ |
| 80 | | #define M_CKP (1<<8) /* CKB to +ALU */ |
| 81 | | #define M_MTN (1<<9) /* MEM to -ALU */ |
| 82 | | #define M_MTP (1<<10) /* MEM to +ALU */ |
| 83 | | #define M_NATN (1<<11) /* ~ACC to -ALU */ |
| 84 | | #define M_NE (1<<12) /* COMP to STATUS */ |
| 85 | | #define M_STO (1<<13) /* ACC to MEM */ |
| 86 | | #define M_STSL (1<<14) /* STATUS to Status Latch */ |
| 87 | | #define M_YTP (1<<15) /* Y to +ALU */ |
| 72 | #define M_15TN 0x00000001 /* 15 to -ALU */ |
| 73 | #define M_ATN 0x00000002 /* ACC to -ALU */ |
| 74 | #define M_AUTA 0x00000004 /* ALU to ACC */ |
| 75 | #define M_AUTY 0x00000008 /* ALU to Y */ |
| 76 | #define M_C8 0x00000010 /* CARRY8 to STATUS */ |
| 77 | #define M_CIN 0x00000020 /* Carry In to ALU */ |
| 78 | #define M_CKM 0x00000040 /* CKB to MEM */ |
| 79 | #define M_CKN 0x00000080 /* CKB to -ALU */ |
| 80 | #define M_CKP 0x00000100 /* CKB to +ALU */ |
| 81 | #define M_MTN 0x00000200 /* MEM to -ALU */ |
| 82 | #define M_MTP 0x00000400 /* MEM to +ALU */ |
| 83 | #define M_NATN 0x00000800 /* ~ACC to -ALU */ |
| 84 | #define M_NE 0x00001000 /* COMP to STATUS */ |
| 85 | #define M_STO 0x00002000 /* ACC to MEM */ |
| 86 | #define M_STSL 0x00004000 /* STATUS to Status Latch */ |
| 87 | #define M_YTP 0x00008000 /* Y to +ALU */ |
| 88 | 88 | |
| 89 | | #define M_CME (1<<16) /* Conditional Memory Enable */ |
| 90 | | #define M_DMTP (1<<17) /* DAM to +ALU */ |
| 91 | | #define M_NDMTP (1<<18) /* ~DAM to +ALU */ |
| 92 | | #define M_SSE (1<<19) /* Special Status Enable */ |
| 93 | | #define M_SSS (1<<20) /* Special Status Sample */ |
| 89 | #define M_CME 0x00010000 /* Conditional Memory Enable */ |
| 90 | #define M_DMTP 0x00020000 /* DAM to +ALU */ |
| 91 | #define M_NDMTP 0x00040000 /* ~DAM to +ALU */ |
| 92 | #define M_SSE 0x00080000 /* Special Status Enable */ |
| 93 | #define M_SSS 0x00100000 /* Special Status Sample */ |
| 94 | 94 | |
| 95 | | #define M_RSTR (1<<21) /* -> line #36, F_RSTR (TMS02x0 custom) */ |
| 96 | | #define M_UNK1 (1<<22) /* -> line #37, F_???? (TMS0270 custom) */ |
| 95 | #define M_RSTR 0x00200000 /* -> line #36, F_RSTR (TMS02x0 custom) */ |
| 96 | #define M_UNK1 0x00400000 /* -> line #37, F_???? (TMS0270 custom) */ |
| 97 | 97 | |
| 98 | 98 | /* Standard/fixed instructions - these are documented more in their specific handlers below */ |
| 99 | | #define F_BR (1<<0) |
| 100 | | #define F_CALL (1<<1) |
| 101 | | #define F_CLO (1<<2) |
| 102 | | #define F_COMC (1<<3) |
| 103 | | #define F_COMX (1<<4) |
| 104 | | #define F_COMX8 (1<<5) |
| 105 | | #define F_LDP (1<<6) |
| 106 | | #define F_LDX (1<<7) |
| 107 | | #define F_RBIT (1<<8) |
| 108 | | #define F_RETN (1<<9) |
| 109 | | #define F_RSTR (1<<10) |
| 110 | | #define F_SBIT (1<<11) |
| 111 | | #define F_SETR (1<<12) |
| 112 | | #define F_TDO (1<<13) |
| 113 | | #define F_TPC (1<<14) |
| 99 | #define F_BR 0x00000001 |
| 100 | #define F_CALL 0x00000002 |
| 101 | #define F_CLO 0x00000004 |
| 102 | #define F_COMC 0x00000008 |
| 103 | #define F_COMX 0x00000010 |
| 104 | #define F_COMX8 0x00000020 |
| 105 | #define F_LDP 0x00000040 |
| 106 | #define F_LDX 0x00000080 |
| 107 | #define F_RBIT 0x00000100 |
| 108 | #define F_RETN 0x00000200 |
| 109 | #define F_RSTR 0x00000400 |
| 110 | #define F_SBIT 0x00000800 |
| 111 | #define F_SETR 0x00001000 |
| 112 | #define F_TDO 0x00002000 |
| 114 | 113 | |
| 115 | | #define F_OFF (1<<15) |
| 116 | | #define F_REAC (1<<16) |
| 117 | | #define F_SAL (1<<17) |
| 118 | | #define F_SBL (1<<18) |
| 119 | | #define F_SEAC (1<<19) |
| 120 | | #define F_XDA (1<<20) |
| 114 | #define F_OFF 0x00004000 |
| 115 | #define F_REAC 0x00008000 |
| 116 | #define F_SAL 0x00010000 |
| 117 | #define F_SBL 0x00020000 |
| 118 | #define F_SEAC 0x00040000 |
| 119 | #define F_XDA 0x00080000 |
| 121 | 120 | |
| 122 | 121 | |
| 123 | 122 | // supported types: |
| r243832 | r243833 | |
| 133 | 132 | // - 20-term output PLA(opla) at the top-left |
| 134 | 133 | // - the ALU is between the opla and mpla |
| 135 | 134 | const device_type TMS1000 = &device_creator<tms1000_cpu_device>; // 28-pin DIP, 11 R pins |
| 136 | | const device_type TMS1070 = &device_creator<tms1070_cpu_device>; // almost same as tms1000, just supports higher voltage |
| 135 | const device_type TMS1070 = &device_creator<tms1070_cpu_device>; // same as tms1000, just supports higher voltage |
| 137 | 136 | const device_type TMS1200 = &device_creator<tms1200_cpu_device>; // 40-pin DIP, 13 R pins |
| 138 | 137 | // TMS1270 has 10 O pins, how does that work? |
| 139 | 138 | |
| 140 | 139 | // TMS1100 is nearly the same as TMS1000, some different opcodes, and with double the RAM and ROM |
| 141 | 140 | const device_type TMS1100 = &device_creator<tms1100_cpu_device>; // 28-pin DIP, 11 R pins |
| 142 | | const device_type TMS1170 = &device_creator<tms1170_cpu_device>; // almost same as tms1100, just supports higher voltage |
| 143 | 141 | const device_type TMS1300 = &device_creator<tms1300_cpu_device>; // 40-pin DIP, 16 R pins |
| 144 | | const device_type TMS1370 = &device_creator<tms1370_cpu_device>; // almost same as tms1300, just supports higher voltage |
| 145 | 142 | |
| 146 | | // TMS1400 follows the TMS1100, it doubles the ROM size again (4 chapters of 16 pages), and adds a 3-level callstack |
| 147 | | // - rotate the view and mirror the OR-mask to get the proper layout of the mpla, the default is identical to tms1100 |
| 148 | | // - the opla size is increased from 20 to 32 terms |
| 149 | | const device_type TMS1400 = &device_creator<tms1400_cpu_device>; // 28-pin DIP, 11 R pins |
| 150 | | const device_type TMS1470 = &device_creator<tms1470_cpu_device>; // almost same as tms1400, just supports higher voltage |
| 151 | | |
| 152 | 143 | // TMS0980 |
| 153 | 144 | // - 64x9bit RAM array at the bottom-left (set up as 144x4) |
| 154 | 145 | // - 2048x9bit ROM array at the bottom-left |
| r243832 | r243833 | |
| 186 | 177 | AM_RANGE(0x000, 0x7ff) AM_ROM |
| 187 | 178 | ADDRESS_MAP_END |
| 188 | 179 | |
| 189 | | static ADDRESS_MAP_START(program_12bit_8, AS_PROGRAM, 8, tms1xxx_cpu_device) |
| 190 | | AM_RANGE(0x000, 0xfff) AM_ROM |
| 191 | | ADDRESS_MAP_END |
| 192 | 180 | |
| 193 | | |
| 194 | 181 | static ADDRESS_MAP_START(data_64x4, AS_DATA, 8, tms1xxx_cpu_device) |
| 195 | 182 | AM_RANGE(0x00, 0x3f) AM_RAM |
| 196 | 183 | ADDRESS_MAP_END |
| r243832 | r243833 | |
| 230 | 217 | : tms1000_cpu_device(mconfig, type, name, tag, owner, clock, o_pins, r_pins, pc_bits, byte_bits, x_bits, prgwidth, program, datawidth, data, shortname, source) |
| 231 | 218 | { } |
| 232 | 219 | |
| 233 | | tms1170_cpu_device::tms1170_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 234 | | : tms1100_cpu_device(mconfig, TMS1170, "TMS1170", tag, owner, clock, 8, 11, 6, 8, 3, 11, ADDRESS_MAP_NAME(program_11bit_8), 7, ADDRESS_MAP_NAME(data_128x4), "tms1170", __FILE__) |
| 235 | | { } |
| 236 | | |
| 237 | 220 | tms1300_cpu_device::tms1300_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 238 | | : tms1100_cpu_device(mconfig, TMS1300, "TMS1300", tag, owner, clock, 8, 16, 6, 8, 3, 11, ADDRESS_MAP_NAME(program_11bit_8), 7, ADDRESS_MAP_NAME(data_128x4), "tms1300", __FILE__) |
| 221 | : tms1100_cpu_device(mconfig, TMS1300, "TMS1200", tag, owner, clock, 8, 16, 6, 8, 3, 11, ADDRESS_MAP_NAME(program_11bit_8), 7, ADDRESS_MAP_NAME(data_128x4), "tms1300", __FILE__) |
| 239 | 222 | { } |
| 240 | 223 | |
| 241 | | tms1370_cpu_device::tms1370_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 242 | | : tms1100_cpu_device(mconfig, TMS1370, "TMS1370", tag, owner, clock, 8, 16, 6, 8, 3, 11, ADDRESS_MAP_NAME(program_11bit_8), 7, ADDRESS_MAP_NAME(data_128x4), "tms1370", __FILE__) |
| 243 | | { } |
| 244 | 224 | |
| 245 | | |
| 246 | | tms1400_cpu_device::tms1400_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 247 | | : tms1100_cpu_device(mconfig, TMS1400, "TMS1400", tag, owner, clock, 8, 11, 6, 8, 3, 12, ADDRESS_MAP_NAME(program_12bit_8), 7, ADDRESS_MAP_NAME(data_128x4), "tms1400", __FILE__) |
| 248 | | { } |
| 249 | | |
| 250 | | tms1400_cpu_device::tms1400_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT8 o_pins, UINT8 r_pins, UINT8 pc_bits, UINT8 byte_bits, UINT8 x_bits, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source) |
| 251 | | : tms1100_cpu_device(mconfig, type, name, tag, owner, clock, o_pins, r_pins, pc_bits, byte_bits, x_bits, prgwidth, program, datawidth, data, shortname, source) |
| 252 | | { } |
| 253 | | |
| 254 | | tms1470_cpu_device::tms1470_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 255 | | : tms1400_cpu_device(mconfig, TMS1470, "TMS1470", tag, owner, clock, 8, 10, 6, 8, 3, 12, ADDRESS_MAP_NAME(program_12bit_8), 7, ADDRESS_MAP_NAME(data_128x4), "tms1470", __FILE__) |
| 256 | | { } |
| 257 | | |
| 258 | | |
| 259 | 225 | tms0970_cpu_device::tms0970_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 260 | 226 | : tms1000_cpu_device(mconfig, TMS0970, "TMS0970", tag, owner, clock, 8, 11, 6, 8, 2, 10, ADDRESS_MAP_NAME(program_10bit_8), 6, ADDRESS_MAP_NAME(data_64x4), "tms0970", __FILE__) |
| 261 | 227 | { } |
| r243832 | r243833 | |
| 298 | 264 | } |
| 299 | 265 | |
| 300 | 266 | |
| 301 | | static MACHINE_CONFIG_FRAGMENT(tms1400) |
| 302 | | |
| 303 | | // microinstructions PLA, output PLA |
| 304 | | MCFG_PLA_ADD("mpla", 8, 16, 30) |
| 305 | | MCFG_PLA_FILEFORMAT(PLA_FMT_BERKELEY) |
| 306 | | MCFG_PLA_ADD("opla", 5, 8, 32) |
| 307 | | MCFG_PLA_FILEFORMAT(PLA_FMT_BERKELEY) |
| 308 | | MACHINE_CONFIG_END |
| 309 | | |
| 310 | | machine_config_constructor tms1400_cpu_device::device_mconfig_additions() const |
| 311 | | { |
| 312 | | return MACHINE_CONFIG_NAME(tms1400); |
| 313 | | } |
| 314 | | |
| 315 | | |
| 316 | 267 | static MACHINE_CONFIG_FRAGMENT(tms0970) |
| 317 | 268 | |
| 318 | 269 | // main opcodes PLA, microinstructions PLA, output PLA, segment PLA |
| r243832 | r243833 | |
| 631 | 582 | for (int i = 0x3c; i < 0x40; i++) m_fixed_decode[i] = 0; |
| 632 | 583 | } |
| 633 | 584 | |
| 634 | | void tms1400_cpu_device::device_reset() |
| 635 | | { |
| 636 | | tms1100_cpu_device::device_reset(); |
| 637 | 585 | |
| 638 | | // small differences in 00-3f area |
| 639 | | m_fixed_decode[0x09] = F_COMX; // ! |
| 640 | | m_fixed_decode[0x0b] = F_TPC; |
| 641 | | } |
| 642 | | |
| 643 | | |
| 644 | 586 | void tms0970_cpu_device::device_reset() |
| 645 | 587 | { |
| 646 | 588 | // common reset |
| r243832 | r243833 | |
| 957 | 899 | // fixed opcode set |
| 958 | 900 | //------------------------------------------------- |
| 959 | 901 | |
| 960 | | // handle branches: |
| 961 | | // note: add(latch) and bl(branch latch) are specific to 0980 series, |
| 962 | | // c(chapter) bits are specific to 1100(and 1400) series |
| 963 | | |
| 964 | 902 | // TMS1000/common: |
| 965 | 903 | |
| 966 | | void tms1xxx_cpu_device::op_br() |
| 967 | | { |
| 968 | | // BR/BL: conditional branch |
| 969 | | if (!m_status) |
| 970 | | return; |
| 971 | | |
| 972 | | if (!m_clatch) |
| 973 | | m_pa = m_pb; |
| 974 | | m_ca = m_cb; |
| 975 | | m_pc = m_opcode & m_pc_mask; |
| 976 | | } |
| 977 | | |
| 978 | | void tms1xxx_cpu_device::op_call() |
| 979 | | { |
| 980 | | // CALL/CALLL: conditional call |
| 981 | | if (!m_status) |
| 982 | | return; |
| 983 | | |
| 984 | | UINT8 prev_pa = m_pa; |
| 985 | | if (!m_clatch) |
| 986 | | { |
| 987 | | m_sr = m_pc; |
| 988 | | m_clatch = 1; |
| 989 | | m_pa = m_pb; |
| 990 | | m_cs = m_ca; |
| 991 | | } |
| 992 | | m_ca = m_cb; |
| 993 | | m_pb = prev_pa; |
| 994 | | m_pc = m_opcode & m_pc_mask; |
| 995 | | } |
| 996 | | |
| 997 | | void tms1xxx_cpu_device::op_retn() |
| 998 | | { |
| 999 | | // RETN: return from subroutine |
| 1000 | | if (m_clatch) |
| 1001 | | { |
| 1002 | | m_pc = m_sr; |
| 1003 | | m_clatch = 0; |
| 1004 | | m_ca = m_cs; |
| 1005 | | } |
| 1006 | | m_add = 0; |
| 1007 | | m_bl = 0; |
| 1008 | | m_pa = m_pb; |
| 1009 | | } |
| 1010 | | |
| 1011 | | |
| 1012 | | // TMS1400-specific |
| 1013 | | |
| 1014 | | void tms1400_cpu_device::op_br() |
| 1015 | | { |
| 1016 | | // BR/BL: conditional branch |
| 1017 | | if (!m_status) |
| 1018 | | return; |
| 1019 | | |
| 1020 | | //.. |
| 1021 | | } |
| 1022 | | |
| 1023 | | void tms1400_cpu_device::op_call() |
| 1024 | | { |
| 1025 | | // CALL/CALLL: conditional call |
| 1026 | | if (!m_status) |
| 1027 | | return; |
| 1028 | | |
| 1029 | | //.. |
| 1030 | | } |
| 1031 | | |
| 1032 | | void tms1400_cpu_device::op_retn() |
| 1033 | | { |
| 1034 | | // RETN: return from subroutine |
| 1035 | | //.. |
| 1036 | | } |
| 1037 | | |
| 1038 | | |
| 1039 | | // handle other: |
| 1040 | | |
| 1041 | | // TMS1000/common: |
| 1042 | | |
| 1043 | 904 | void tms1xxx_cpu_device::op_sbit() |
| 1044 | 905 | { |
| 1045 | 906 | // SBIT: set memory bit |
| r243832 | r243833 | |
| 1131 | 992 | } |
| 1132 | 993 | |
| 1133 | 994 | |
| 1134 | | // TMS1400-specific |
| 1135 | | |
| 1136 | | void tms1xxx_cpu_device::op_tpc() |
| 1137 | | { |
| 1138 | | // TPC: transfer page buffer to chapter buffer |
| 1139 | | m_cb = m_pb & 3; |
| 1140 | | } |
| 1141 | | |
| 1142 | | |
| 1143 | 995 | // TMS0970-specific (and possibly child classes) |
| 1144 | 996 | void tms0970_cpu_device::op_setr() |
| 1145 | 997 | { |
| r243832 | r243833 | |
| 1243 | 1095 | // fetch: rom address 1/2 |
| 1244 | 1096 | |
| 1245 | 1097 | // execute: br/call 2/2 |
| 1246 | | if (m_fixed & F_BR) op_br(); |
| 1247 | | if (m_fixed & F_CALL) op_call(); |
| 1248 | | if (m_fixed & F_RETN) op_retn(); |
| 1098 | // note: add(latch) and bl(branch latch) are specific to 0980 series, |
| 1099 | // c(chapter) bits are specific to 1100 series |
| 1100 | if (m_status) |
| 1101 | { |
| 1102 | UINT8 new_pc = m_opcode & m_pc_mask; |
| 1249 | 1103 | |
| 1104 | // BR: conditional branch |
| 1105 | if (m_fixed & F_BR) |
| 1106 | { |
| 1107 | if (m_clatch == 0) |
| 1108 | m_pa = m_pb; |
| 1109 | m_ca = m_cb; |
| 1110 | m_pc = new_pc; |
| 1111 | } |
| 1112 | |
| 1113 | // CALL: conditional call |
| 1114 | if (m_fixed & F_CALL) |
| 1115 | { |
| 1116 | UINT8 prev_pa = m_pa; |
| 1117 | if (m_clatch == 0) |
| 1118 | { |
| 1119 | m_sr = m_pc; |
| 1120 | m_clatch = 1; |
| 1121 | m_pa = m_pb; |
| 1122 | m_cs = m_ca; |
| 1123 | } |
| 1124 | m_ca = m_cb; |
| 1125 | m_pb = prev_pa; |
| 1126 | m_pc = new_pc; |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | // RETN: return from subroutine |
| 1131 | if (m_fixed & F_RETN) |
| 1132 | { |
| 1133 | if (m_clatch == 1) |
| 1134 | { |
| 1135 | m_pc = m_sr; |
| 1136 | m_clatch = 0; |
| 1137 | m_ca = m_cs; |
| 1138 | } |
| 1139 | m_add = 0; |
| 1140 | m_bl = 0; |
| 1141 | m_pa = m_pb; |
| 1142 | } |
| 1143 | |
| 1250 | 1144 | // execute: k input valid, read ram, clear alu inputs |
| 1251 | 1145 | dynamic_output(); |
| 1252 | 1146 | set_cki_bus(); |
| r243832 | r243833 | |
| 1322 | 1216 | if (m_fixed & F_COMX8) op_comx8(); |
| 1323 | 1217 | if (m_fixed & F_LDP) op_ldp(); |
| 1324 | 1218 | if (m_fixed & F_COMC) op_comc(); |
| 1325 | | if (m_fixed & F_TPC) op_tpc(); |
| 1326 | 1219 | if (m_fixed & F_OFF) op_off(); |
| 1327 | 1220 | if (m_fixed & F_SEAC) op_seac(); |
| 1328 | 1221 | if (m_fixed & F_REAC) op_reac(); |
branches/kale/src/emu/netlist/analog/nld_bjt.c
| r243832 | r243833 | |
| 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 | |
| r243832 | r243833 | |
| 75 | 75 | connect(m_RB.m_P, m_BC_dummy.m_P); |
| 76 | 76 | connect(m_RC.m_P, m_BC_dummy.m_N); |
| 77 | 77 | |
| 78 | | save(NLNAME(m_state_on)); |
| 78 | save(NAME(m_state_on)); |
| 79 | 79 | |
| 80 | 80 | m_RB.set(netlist().gmin(), 0.0, 0.0); |
| 81 | 81 | m_RC.set(netlist().gmin(), 0.0, 0.0); |
| r243832 | r243833 | |
| 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 | |
| r243832 | r243833 | |
| 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()); |
branches/kale/src/emu/netlist/analog/nld_bjt.h
| r243832 | r243833 | |
| 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 |
| r243832 | r243833 | |
| 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); |
| r243832 | r243833 | |
| 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: |
| r243832 | r243833 | |
| 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); |
| r243832 | r243833 | |
| 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 | }; |
branches/kale/src/emu/netlist/analog/nld_ms_direct.h
| r243832 | r243833 | |
| 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; |
| r243832 | r243833 | |
| 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 | // ---------------------------------------------------------------------------------------- |
| r243832 | r243833 | |
| 69 | 69 | { |
| 70 | 70 | //delete[] m_A[k]; |
| 71 | 71 | } |
| 72 | | for (int k = 0; k < N(); k++) |
| 73 | | { |
| 74 | | nl_free(m_terms[k]); |
| 75 | | nl_free(m_row_ops[k]); |
| 76 | | } |
| 77 | | nl_free(m_row_ops[N()]); |
| 78 | | //delete[] m_last_RHS; |
| 72 | //delete[] m_last_RHS; |
| 79 | 73 | //delete[] m_RHS; |
| 80 | | nl_free_array(m_terms); |
| 81 | | nl_free_array(m_rails_temp); |
| 74 | delete[] m_terms; |
| 75 | delete[] m_rails_temp; |
| 82 | 76 | //delete[] m_row_ops; |
| 83 | 77 | |
| 84 | 78 | } |
| 85 | 79 | |
| 86 | 80 | template <int m_N, int _storage_N> |
| 87 | | ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep() |
| 81 | ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep() |
| 88 | 82 | { |
| 89 | | nl_double new_solver_timestep = m_params.m_max_timestep; |
| 83 | double new_solver_timestep = m_params.m_max_timestep; |
| 90 | 84 | |
| 91 | 85 | if (m_params.m_dynamic) |
| 92 | 86 | { |
| r243832 | r243833 | |
| 103 | 97 | { |
| 104 | 98 | netlist_analog_net_t *n = m_nets[k]; |
| 105 | 99 | #endif |
| 106 | | const nl_double DD_n = (n->m_cur_Analog - m_last_V[k]); |
| 107 | | const nl_double hn = current_timestep(); |
| 100 | const double DD_n = (n->m_cur_Analog - m_last_V[k]); |
| 101 | const double hn = current_timestep(); |
| 108 | 102 | |
| 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; |
| 103 | double DD2 = (DD_n / hn - n->m_DD_n_m_1 / n->m_h_n_m_1) / (hn + n->m_h_n_m_1); |
| 104 | double new_net_timestep; |
| 111 | 105 | |
| 112 | 106 | n->m_h_n_m_1 = hn; |
| 113 | 107 | n->m_DD_n_m_1 = DD_n; |
| r243832 | r243833 | |
| 236 | 230 | for (int i=0; i < N(); i++) |
| 237 | 231 | m_A[k][i] = 0.0; |
| 238 | 232 | |
| 239 | | nl_double rhsk = 0.0; |
| 240 | | nl_double akk = 0.0; |
| 233 | double rhsk = 0.0; |
| 234 | double akk = 0.0; |
| 241 | 235 | { |
| 242 | 236 | 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(); |
| 237 | const double * RESTRICT gt = m_terms[k]->gt(); |
| 238 | const double * RESTRICT go = m_terms[k]->go(); |
| 239 | const double * RESTRICT Idr = m_terms[k]->Idr(); |
| 246 | 240 | #if VECTALT |
| 247 | 241 | |
| 248 | 242 | for (int i = 0; i < terms_count; i++) |
| r243832 | r243833 | |
| 253 | 247 | #else |
| 254 | 248 | m_terms[k]->ops()->sum2(Idr, gt, rhsk, akk); |
| 255 | 249 | #endif |
| 256 | | nl_double * const * RESTRICT other_cur_analog = m_terms[k]->other_curanalog(); |
| 250 | double * const * RESTRICT other_cur_analog = m_terms[k]->other_curanalog(); |
| 257 | 251 | for (int i = m_terms[k]->m_railstart; i < terms_count; i++) |
| 258 | 252 | { |
| 259 | 253 | //rhsk = rhsk + go[i] * terms[i]->m_otherterm->net().as_analog().Q_Analog(); |
| r243832 | r243833 | |
| 272 | 266 | m_A[k][k] += 1.0; |
| 273 | 267 | { |
| 274 | 268 | const int *net_other = m_terms[k]->net_other(); |
| 275 | | const nl_double *go = m_terms[k]->go(); |
| 269 | const double *go = m_terms[k]->go(); |
| 276 | 270 | const int railstart = m_terms[k]->m_railstart; |
| 277 | 271 | |
| 278 | 272 | for (int i = 0; i < railstart; i++) |
| r243832 | r243833 | |
| 285 | 279 | m_A[k][k] += akk; |
| 286 | 280 | { |
| 287 | 281 | const int * RESTRICT net_other = m_terms[k]->net_other(); |
| 288 | | const nl_double * RESTRICT go = m_terms[k]->go(); |
| 282 | const double * RESTRICT go = m_terms[k]->go(); |
| 289 | 283 | const int railstart = m_terms[k]->m_railstart; |
| 290 | 284 | |
| 291 | 285 | for (int i = 0; i < railstart; i++) |
| r243832 | r243833 | |
| 299 | 293 | |
| 300 | 294 | template <int m_N, int _storage_N> |
| 301 | 295 | ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::gauss_LE( |
| 302 | | nl_double (* RESTRICT x)) |
| 296 | double (* RESTRICT x)) |
| 303 | 297 | { |
| 304 | 298 | #if 0 |
| 305 | 299 | for (int i = 0; i < N(); i++) |
| r243832 | r243833 | |
| 336 | 330 | } |
| 337 | 331 | |
| 338 | 332 | /* FIXME: Singular matrix? */ |
| 339 | | const nl_double f = 1.0 / m_A[i][i]; |
| 333 | const double f = 1.0 / m_A[i][i]; |
| 340 | 334 | |
| 341 | 335 | /* Eliminate column i from row j */ |
| 342 | 336 | |
| 343 | 337 | for (int j = i + 1; j < kN; j++) |
| 344 | 338 | { |
| 345 | | const nl_double f1 = - m_A[j][i] * f; |
| 339 | const double f1 = - m_A[j][i] * f; |
| 346 | 340 | if (f1 != 0.0) |
| 347 | 341 | { |
| 348 | 342 | #if 0 && VECTALT |
| r243832 | r243833 | |
| 359 | 353 | /* back substitution */ |
| 360 | 354 | for (int j = kN - 1; j >= 0; j--) |
| 361 | 355 | { |
| 362 | | nl_double tmp = 0; |
| 356 | double tmp = 0; |
| 363 | 357 | |
| 364 | 358 | for (int k = j + 1; k < kN; k++) |
| 365 | 359 | tmp += m_A[j][k] * x[k]; |
| r243832 | r243833 | |
| 380 | 374 | } |
| 381 | 375 | |
| 382 | 376 | 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)) |
| 377 | ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta( |
| 378 | const double (* RESTRICT V)) |
| 385 | 379 | { |
| 386 | | nl_double cerr = 0; |
| 387 | | nl_double cerr2 = 0; |
| 380 | double cerr = 0; |
| 381 | double cerr2 = 0; |
| 388 | 382 | for (int i = 0; i < this->N(); i++) |
| 389 | 383 | { |
| 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]); |
| 384 | const double e = (V[i] - this->m_nets[i]->m_cur_Analog); |
| 385 | const double e2 = (m_RHS[i] - this->m_last_RHS[i]); |
| 392 | 386 | cerr = (fabs(e) > cerr ? fabs(e) : cerr); |
| 393 | 387 | cerr2 = (fabs(e2) > cerr2 ? fabs(e2) : cerr2); |
| 394 | 388 | } |
| r243832 | r243833 | |
| 398 | 392 | |
| 399 | 393 | template <int m_N, int _storage_N> |
| 400 | 394 | ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::store( |
| 401 | | const nl_double (* RESTRICT V), const bool store_RHS) |
| 395 | const double (* RESTRICT V), const bool store_RHS) |
| 402 | 396 | { |
| 403 | 397 | for (int i = 0; i < this->N(); i++) |
| 404 | 398 | { |
| r243832 | r243833 | |
| 414 | 408 | } |
| 415 | 409 | |
| 416 | 410 | template <int m_N, int _storage_N> |
| 417 | | ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve() |
| 411 | ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve() |
| 418 | 412 | { |
| 419 | 413 | solve_base<netlist_matrix_solver_direct_t>(this); |
| 420 | 414 | return this->compute_next_timestep(); |
| r243832 | r243833 | |
| 424 | 418 | template <int m_N, int _storage_N> |
| 425 | 419 | ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic() |
| 426 | 420 | { |
| 427 | | nl_double new_v[_storage_N] = { 0.0 }; |
| 421 | double new_v[_storage_N] = { 0.0 }; |
| 428 | 422 | |
| 429 | 423 | this->gauss_LE(new_v); |
| 430 | 424 | |
| 431 | 425 | if (this->is_dynamic()) |
| 432 | 426 | { |
| 433 | | nl_double err = delta(new_v); |
| 427 | double err = delta(new_v); |
| 434 | 428 | |
| 435 | 429 | store(new_v, true); |
| 436 | 430 | |
| r243832 | r243833 | |
| 458 | 452 | , m_dim(size) |
| 459 | 453 | , m_lp_fact(0) |
| 460 | 454 | { |
| 461 | | m_terms = nl_alloc_array(terms_t *, N()); |
| 462 | | m_rails_temp = nl_alloc_array(terms_t, N()); |
| 455 | m_terms = new terms_t *[N()]; |
| 456 | m_rails_temp = new terms_t[N()]; |
| 463 | 457 | |
| 464 | 458 | for (int k = 0; k < N(); k++) |
| 465 | 459 | { |
| 466 | | m_terms[k] = nl_alloc(terms_t); |
| 460 | m_terms[k] = new terms_t; |
| 467 | 461 | m_row_ops[k] = vector_ops_t::create_ops(k); |
| 468 | 462 | } |
| 469 | 463 | m_row_ops[N()] = vector_ops_t::create_ops(N()); |
| r243832 | r243833 | |
| 475 | 469 | , m_dim(size) |
| 476 | 470 | , m_lp_fact(0) |
| 477 | 471 | { |
| 478 | | m_terms = nl_alloc_array(terms_t *, N()); |
| 479 | | m_rails_temp = nl_alloc_array(terms_t, N()); |
| 472 | m_terms = new terms_t *[N()]; |
| 473 | m_rails_temp = new terms_t[N()]; |
| 480 | 474 | |
| 481 | 475 | for (int k = 0; k < N(); k++) |
| 482 | 476 | { |
| 483 | | m_terms[k] = nl_alloc(terms_t); |
| 477 | m_terms[k] = new terms_t; |
| 484 | 478 | m_row_ops[k] = vector_ops_t::create_ops(k); |
| 485 | 479 | } |
| 486 | 480 | m_row_ops[N()] = vector_ops_t::create_ops(N()); |
branches/kale/src/emu/netlist/analog/nld_ms_gauss_seidel.h
| r243832 | r243833 | |
| 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 | |
| r243832 | r243833 | |
| 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 |
| r243832 | r243833 | |
| 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; |
| r243832 | r243833 | |
| 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; |
| r243832 | r243833 | |
| 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]; |
| r243832 | r243833 | |
| 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); |
| r243832 | r243833 | |
| 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 |
| r243832 | r243833 | |
| 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]; |
| r243832 | r243833 | |
| 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 | } |
| r243832 | r243833 | |
| 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) )); |
| r243832 | r243833 | |
| 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 | { |
| r243832 | r243833 | |
| 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; |
| r243832 | r243833 | |
| 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; |
branches/kale/src/emu/netlist/analog/nld_solver.c
| r243832 | r243833 | |
| 44 | 44 | switch (size) |
| 45 | 45 | { |
| 46 | 46 | case 1: |
| 47 | | return nl_alloc(vector_ops_impl_t<1>); |
| 47 | return new vector_ops_impl_t<1>(); |
| 48 | 48 | case 2: |
| 49 | | return nl_alloc(vector_ops_impl_t<2>); |
| 49 | return new vector_ops_impl_t<2>(); |
| 50 | 50 | case 3: |
| 51 | | return nl_alloc(vector_ops_impl_t<3>); |
| 51 | return new vector_ops_impl_t<3>(); |
| 52 | 52 | case 4: |
| 53 | | return nl_alloc(vector_ops_impl_t<4>); |
| 53 | return new vector_ops_impl_t<4>(); |
| 54 | 54 | case 5: |
| 55 | | return nl_alloc(vector_ops_impl_t<5>); |
| 55 | return new vector_ops_impl_t<5>(); |
| 56 | 56 | case 6: |
| 57 | | return nl_alloc(vector_ops_impl_t<6>); |
| 57 | return new vector_ops_impl_t<6>(); |
| 58 | 58 | case 7: |
| 59 | | return nl_alloc(vector_ops_impl_t<7>); |
| 59 | return new vector_ops_impl_t<7>(); |
| 60 | 60 | case 8: |
| 61 | | return nl_alloc(vector_ops_impl_t<8>); |
| 61 | return new vector_ops_impl_t<8>(); |
| 62 | 62 | case 9: |
| 63 | | return nl_alloc(vector_ops_impl_t<9>); |
| 63 | return new vector_ops_impl_t<9>(); |
| 64 | 64 | case 10: |
| 65 | | return nl_alloc(vector_ops_impl_t<10>); |
| 65 | return new vector_ops_impl_t<10>(); |
| 66 | 66 | case 11: |
| 67 | | return nl_alloc(vector_ops_impl_t<11>); |
| 67 | return new vector_ops_impl_t<11>(); |
| 68 | 68 | case 12: |
| 69 | | return nl_alloc(vector_ops_impl_t<12>); |
| 69 | return new vector_ops_impl_t<12>(); |
| 70 | 70 | default: |
| 71 | | return nl_alloc(vector_ops_impl_t<0>, size); |
| 71 | return new vector_ops_impl_t<0>(size); |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| r243832 | r243833 | |
| 91 | 91 | m_term[i]->m_Idr1 = &m_Idr[i]; |
| 92 | 92 | m_other_curanalog[i] = &m_term[i]->m_otherterm->net().as_analog().m_cur_Analog; |
| 93 | 93 | } |
| 94 | |
| 95 | m_ops = vector_ops_t::create_ops(m_gt.count()); |
| 94 | 96 | } |
| 95 | 97 | |
| 96 | 98 | // ---------------------------------------------------------------------------------------- |
| r243832 | r243833 | |
| 110 | 112 | ATTR_COLD netlist_matrix_solver_t::~netlist_matrix_solver_t() |
| 111 | 113 | { |
| 112 | 114 | for (int i = 0; i < m_inps.count(); i++) |
| 113 | | global_free(m_inps[i]); |
| 115 | delete m_inps[i]; |
| 114 | 116 | } |
| 115 | 117 | |
| 116 | 118 | ATTR_COLD void netlist_matrix_solver_t::setup(netlist_analog_net_t::list_t &nets) |
| r243832 | r243833 | |
| 174 | 176 | |
| 175 | 177 | if (net_proxy_output == NULL) |
| 176 | 178 | { |
| 177 | | net_proxy_output = nl_alloc(netlist_analog_output_t); |
| 179 | net_proxy_output = new netlist_analog_output_t(); |
| 178 | 180 | net_proxy_output->init_object(*this, this->name() + "." + pstring::sprintf("m%d", m_inps.count())); |
| 179 | 181 | m_inps.add(net_proxy_output); |
| 180 | 182 | net_proxy_output->m_proxied_net = &p->net().as_analog(); |
| r243832 | r243833 | |
| 233 | 235 | |
| 234 | 236 | ATTR_COLD void netlist_matrix_solver_t::update() |
| 235 | 237 | { |
| 236 | | const nl_double new_timestep = solve(); |
| 238 | const double new_timestep = solve(); |
| 237 | 239 | |
| 238 | 240 | if (m_params.m_dynamic && is_timestep() && new_timestep > 0) |
| 239 | 241 | m_Q_sync.net().reschedule_in_queue(netlist_time::from_double(new_timestep)); |
| r243832 | r243833 | |
| 241 | 243 | |
| 242 | 244 | ATTR_COLD void netlist_matrix_solver_t::update_forced() |
| 243 | 245 | { |
| 244 | | ATTR_UNUSED const nl_double new_timestep = solve(); |
| 246 | ATTR_UNUSED const double new_timestep = solve(); |
| 245 | 247 | |
| 246 | 248 | if (m_params.m_dynamic && is_timestep()) |
| 247 | 249 | m_Q_sync.net().reschedule_in_queue(netlist_time::from_double(m_params.m_min_timestep)); |
| r243832 | r243833 | |
| 249 | 251 | |
| 250 | 252 | ATTR_HOT void netlist_matrix_solver_t::step(const netlist_time delta) |
| 251 | 253 | { |
| 252 | | const nl_double dd = delta.as_double(); |
| 254 | const double dd = delta.as_double(); |
| 253 | 255 | for (int k=0; k < m_step_devices.count(); k++) |
| 254 | 256 | m_step_devices[k]->step_time(dd); |
| 255 | 257 | } |
| r243832 | r243833 | |
| 284 | 286 | } |
| 285 | 287 | } |
| 286 | 288 | |
| 287 | | ATTR_HOT nl_double netlist_matrix_solver_t::solve() |
| 289 | ATTR_HOT double netlist_matrix_solver_t::solve() |
| 288 | 290 | { |
| 289 | 291 | netlist_time now = netlist().time(); |
| 290 | 292 | netlist_time delta = now - m_last_step; |
| r243832 | r243833 | |
| 300 | 302 | |
| 301 | 303 | step(delta); |
| 302 | 304 | |
| 303 | | const nl_double next_time_step = vsolve(); |
| 305 | const double next_time_step = vsolve(); |
| 304 | 306 | |
| 305 | 307 | update_inputs(); |
| 306 | 308 | return next_time_step; |
| r243832 | r243833 | |
| 348 | 350 | register_param("GMIN", m_gmin, NETLIST_GMIN_DEFAULT); |
| 349 | 351 | register_param("DYNAMIC_TS", m_dynamic, 0); |
| 350 | 352 | register_param("LTE", m_lte, 5e-5); // diff/timestep |
| 351 | | register_param("MIN_TIMESTEP", m_min_timestep, 1e-6); // nl_double timestep resolution |
| 353 | register_param("MIN_TIMESTEP", m_min_timestep, 1e-6); // double timestep resolution |
| 352 | 354 | |
| 353 | 355 | // internal staff |
| 354 | 356 | |
| r243832 | r243833 | |
| 378 | 380 | while (e != NULL) |
| 379 | 381 | { |
| 380 | 382 | netlist_matrix_solver_t * const *en = m_mat_solvers.next(e); |
| 381 | | global_free(*e); |
| 383 | delete *e; |
| 382 | 384 | e = en; |
| 383 | 385 | } |
| 384 | 386 | |
| r243832 | r243833 | |
| 417 | 419 | if (m_mat_solvers[i]->is_timestep()) |
| 418 | 420 | { |
| 419 | 421 | // Ignore return value |
| 420 | | ATTR_UNUSED const nl_double ts = m_mat_solvers[i]->solve(); |
| 422 | ATTR_UNUSED const double ts = m_mat_solvers[i]->solve(); |
| 421 | 423 | } |
| 422 | 424 | } |
| 423 | 425 | #endif |
| r243832 | r243833 | |
| 433 | 435 | netlist_matrix_solver_t * NETLIB_NAME(solver)::create_solver(int size, const int gs_threshold, const bool use_specific) |
| 434 | 436 | { |
| 435 | 437 | if (use_specific && m_N == 1) |
| 436 | | return nl_alloc(netlist_matrix_solver_direct1_t, m_params); |
| 438 | return new netlist_matrix_solver_direct1_t(m_params); |
| 437 | 439 | else if (use_specific && m_N == 2) |
| 438 | | return nl_alloc(netlist_matrix_solver_direct2_t, m_params); |
| 440 | return new netlist_matrix_solver_direct2_t(m_params); |
| 439 | 441 | else |
| 440 | 442 | { |
| 441 | | typedef netlist_matrix_solver_gauss_seidel_t<m_N,_storage_N> solver_N; |
| 442 | 443 | if (size >= gs_threshold) |
| 443 | | return nl_alloc(solver_N, m_params, size); |
| 444 | return new netlist_matrix_solver_gauss_seidel_t<m_N,_storage_N>(m_params, size); |
| 444 | 445 | else |
| 445 | | return nl_alloc(solver_N, m_params, size); |
| 446 | return new netlist_matrix_solver_direct_t<m_N, _storage_N>(m_params, size); |
| 446 | 447 | } |
| 447 | 448 | } |
| 448 | 449 | |
branches/kale/src/emu/netlist/analog/nld_solver.h
| r243832 | r243833 | |
| 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; |
| r243832 | r243833 | |
| 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 | |
| r243832 | r243833 | |
| 88 | 88 | vector_ops_impl_t(int size) |
| 89 | 89 | : vector_ops_t(size) |
| 90 | 90 | { |
| 91 | | nl_assert(m_N == 0); |
| 91 | assert(m_N == 0); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | virtual ~vector_ops_impl_t() {} |
| 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]; |
| r243832 | r243833 | |
| 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]; |
| r243832 | r243833 | |
| 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; |
| r243832 | r243833 | |
| 155 | 155 | NETLIST_PREVENT_COPYING(terms_t) |
| 156 | 156 | |
| 157 | 157 | public: |
| 158 | | ATTR_COLD terms_t() : m_railstart(0) |
| 158 | ATTR_COLD terms_t() : m_railstart(0), m_ops(NULL) |
| 159 | 159 | {} |
| 160 | 160 | |
| 161 | 161 | ATTR_COLD void clear() |
| r243832 | r243833 | |
| 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 | ATTR_HOT vector_ops_t *ops() { return m_ops; } |
| 178 | 179 | |
| 179 | 180 | ATTR_COLD void set_pointers(); |
| 180 | 181 | |
| r243832 | r243833 | |
| 183 | 184 | private: |
| 184 | 185 | plinearlist_t<netlist_terminal_t *> m_term; |
| 185 | 186 | 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; |
| 187 | plinearlist_t<double> m_go; |
| 188 | plinearlist_t<double> m_gt; |
| 189 | plinearlist_t<double> m_Idr; |
| 190 | plinearlist_t<double *> m_other_curanalog; |
| 191 | vector_ops_t * m_ops; |
| 190 | 192 | }; |
| 191 | 193 | |
| 192 | 194 | class netlist_matrix_solver_t : public netlist_device_t |
| r243832 | r243833 | |
| 209 | 211 | template<class C> |
| 210 | 212 | void solve_base(C *p); |
| 211 | 213 | |
| 212 | | ATTR_HOT nl_double solve(); |
| 214 | ATTR_HOT double solve(); |
| 213 | 215 | |
| 214 | 216 | ATTR_HOT inline bool is_dynamic() { return m_dynamic_devices.count() > 0; } |
| 215 | 217 | ATTR_HOT inline bool is_timestep() { return m_step_devices.count() > 0; } |
| r243832 | r243833 | |
| 236 | 238 | ATTR_HOT void update_dynamic(); |
| 237 | 239 | |
| 238 | 240 | // should return next time step |
| 239 | | ATTR_HOT virtual nl_double vsolve() = 0; |
| 241 | ATTR_HOT virtual double vsolve() = 0; |
| 240 | 242 | |
| 241 | 243 | ATTR_COLD virtual void add_term(int net_idx, netlist_terminal_t *term) = 0; |
| 242 | 244 | |
| r243832 | r243833 | |
| 249 | 251 | |
| 250 | 252 | const netlist_solver_parameters_t &m_params; |
| 251 | 253 | |
| 252 | | ATTR_HOT inline const nl_double current_timestep() { return m_cur_ts; } |
| 254 | ATTR_HOT inline const double current_timestep() { return m_cur_ts; } |
| 253 | 255 | private: |
| 254 | 256 | |
| 255 | 257 | netlist_time m_last_step; |
| 256 | | nl_double m_cur_ts; |
| 258 | double m_cur_ts; |
| 257 | 259 | dev_list_t m_step_devices; |
| 258 | 260 | dev_list_t m_dynamic_devices; |
| 259 | 261 | |
| r243832 | r243833 | |
| 279 | 281 | |
| 280 | 282 | ATTR_COLD void post_start(); |
| 281 | 283 | |
| 282 | | ATTR_HOT inline nl_double gmin() { return m_gmin.Value(); } |
| 284 | ATTR_HOT inline double gmin() { return m_gmin.Value(); } |
| 283 | 285 | |
| 284 | 286 | protected: |
| 285 | 287 | ATTR_HOT void update(); |
branches/kale/src/emu/netlist/analog/nld_twoterm.h
| r243832 | r243833 | |
| 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); |
| r243832 | r243833 | |
| 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 | } |
| r243832 | r243833 | |
| 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 | |
| r243832 | r243833 | |
| 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 | |
| r243832 | r243833 | |
| 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 | } |
| r243832 | r243833 | |
| 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; |
| r243832 | r243833 | |
| 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 | // ---------------------------------------------------------------------------------------- |
| r243832 | r243833 | |
| 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); |
branches/kale/src/emu/netlist/nl_base.c
| r243832 | r243833 | |
| 9 | 9 | #include "pstring.h" |
| 10 | 10 | #include "nl_util.h" |
| 11 | 11 | |
| 12 | | #include <stdlib.h> // FIXME: only included for atof |
| 13 | | |
| 14 | 12 | const netlist_time netlist_time::zero = netlist_time::from_raw(0); |
| 15 | 13 | |
| 16 | 14 | netlist_logic_family_desc_t netlist_family_TTL = |
| r243832 | r243833 | |
| 152 | 150 | { |
| 153 | 151 | if (!m_nets[i]->isRailNet()) |
| 154 | 152 | { |
| 155 | | global_free(m_nets[i]); |
| 153 | delete m_nets[i]; |
| 156 | 154 | } |
| 157 | 155 | } |
| 158 | 156 | |
| r243832 | r243833 | |
| 166 | 164 | ATTR_COLD void netlist_base_t::save_register() |
| 167 | 165 | { |
| 168 | 166 | save(static_cast<pstate_callback_t &>(m_queue), "m_queue"); |
| 169 | | save(NLNAME(m_time)); |
| 167 | save(NAME(m_time)); |
| 170 | 168 | netlist_object_t::save_register(); |
| 171 | 169 | } |
| 172 | 170 | |
| 173 | | ATTR_HOT const nl_double netlist_base_t::gmin() const |
| 171 | ATTR_HOT const double netlist_base_t::gmin() const |
| 174 | 172 | { |
| 175 | 173 | return solver()->gmin(); |
| 176 | 174 | } |
| r243832 | r243833 | |
| 452 | 450 | } |
| 453 | 451 | |
| 454 | 452 | 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 | 453 | template ATTR_COLD void netlist_device_t::register_param(const pstring &sname, netlist_param_int_t ¶m, const int initialVal); |
| 457 | 454 | template ATTR_COLD void netlist_device_t::register_param(const pstring &sname, netlist_param_logic_t ¶m, const int initialVal); |
| 458 | 455 | template ATTR_COLD void netlist_device_t::register_param(const pstring &sname, netlist_param_str_t ¶m, const char * const initialVal); |
| r243832 | r243833 | |
| 532 | 529 | |
| 533 | 530 | ATTR_COLD void netlist_net_t::register_railterminal(netlist_output_t &mr) |
| 534 | 531 | { |
| 535 | | nl_assert(m_railterminal == NULL); |
| 532 | assert(m_railterminal == NULL); |
| 536 | 533 | m_railterminal = &mr; |
| 537 | 534 | } |
| 538 | 535 | |
| r243832 | r243833 | |
| 548 | 545 | |
| 549 | 546 | ATTR_COLD void netlist_net_t::save_register() |
| 550 | 547 | { |
| 551 | | save(NLNAME(m_time)); |
| 552 | | save(NLNAME(m_active)); |
| 553 | | save(NLNAME(m_in_queue)); |
| 554 | | save(NLNAME(m_cur_Analog)); |
| 555 | | save(NLNAME(m_cur_Q)); |
| 556 | | save(NLNAME(m_new_Q)); |
| 548 | save(NAME(m_time)); |
| 549 | save(NAME(m_active)); |
| 550 | save(NAME(m_in_queue)); |
| 551 | save(NAME(m_cur_Analog)); |
| 552 | save(NAME(m_cur_Q)); |
| 553 | save(NAME(m_new_Q)); |
| 557 | 554 | netlist_object_t::save_register(); |
| 558 | 555 | } |
| 559 | 556 | |
| r243832 | r243833 | |
| 572 | 569 | ATTR_HOT ATTR_ALIGN inline void netlist_net_t::update_devs() |
| 573 | 570 | { |
| 574 | 571 | //assert(m_num_cons != 0); |
| 575 | | nl_assert(this->isRailNet()); |
| 572 | assert(this->isRailNet()); |
| 576 | 573 | |
| 577 | 574 | const UINT32 masks[4] = { 1, 5, 3, 1 }; |
| 578 | 575 | const UINT32 mask = masks[ (m_cur_Q << 1) | m_new_Q ]; |
| r243832 | r243833 | |
| 710 | 707 | |
| 711 | 708 | ATTR_COLD void netlist_analog_net_t::save_register() |
| 712 | 709 | { |
| 713 | | save(NLNAME(m_DD_n_m_1)); |
| 714 | | save(NLNAME(m_h_n_m_1)); |
| 710 | save(NAME(m_DD_n_m_1)); |
| 711 | save(NAME(m_h_n_m_1)); |
| 715 | 712 | netlist_net_t::save_register(); |
| 716 | 713 | } |
| 717 | 714 | |
| r243832 | r243833 | |
| 806 | 803 | |
| 807 | 804 | ATTR_COLD void netlist_terminal_t::save_register() |
| 808 | 805 | { |
| 809 | | save(NLNAME(m_Idr1)); |
| 810 | | save(NLNAME(m_go1)); |
| 811 | | save(NLNAME(m_gt1)); |
| 806 | save(NAME(m_Idr1)); |
| 807 | save(NAME(m_go1)); |
| 808 | save(NAME(m_gt1)); |
| 812 | 809 | netlist_core_terminal_t::save_register(); |
| 813 | 810 | } |
| 814 | 811 | |
| r243832 | r243833 | |
| 875 | 872 | net().as_analog().m_cur_Analog = 0.98; |
| 876 | 873 | } |
| 877 | 874 | |
| 878 | | ATTR_COLD void netlist_analog_output_t::initial(const nl_double val) |
| 875 | ATTR_COLD void netlist_analog_output_t::initial(const double val) |
| 879 | 876 | { |
| 880 | 877 | net().as_analog().m_cur_Analog = val * 0.99; |
| 881 | 878 | } |
| r243832 | r243833 | |
| 932 | 929 | } |
| 933 | 930 | |
| 934 | 931 | |
| 935 | | ATTR_COLD nl_double netlist_param_model_t::model_value(const pstring &entity, const nl_double defval) const |
| 932 | ATTR_COLD double netlist_param_model_t::model_value(const pstring &entity, const double defval) const |
| 936 | 933 | { |
| 937 | 934 | pstring tmp = this->Value(); |
| 938 | 935 | // .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) |
| r243832 | r243833 | |
| 946 | 943 | if (pequal < 0) |
| 947 | 944 | netlist().error("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr()); |
| 948 | 945 | tmp = tmp.substr(pequal+1); |
| 949 | | nl_double factor = 1.0; |
| 946 | double factor = 1.0; |
| 950 | 947 | switch (*(tmp.right(1).cstr())) |
| 951 | 948 | { |
| 952 | 949 | case 'm': factor = 1e-3; break; |
branches/kale/src/emu/netlist/nl_base.h
| r243832 | r243833 | |
| 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 |
| r243832 | r243833 | |
| 444 | 444 | ATTR_HOT inline const state_e state() const { return m_state; } |
| 445 | 445 | ATTR_HOT inline void set_state(const state_e astate) |
| 446 | 446 | { |
| 447 | | nl_assert(astate != STATE_NONEX); |
| 447 | assert(astate != STATE_NONEX); |
| 448 | 448 | m_state = astate; |
| 449 | 449 | } |
| 450 | 450 | |
| r243832 | r243833 | |
| 453 | 453 | protected: |
| 454 | 454 | ATTR_COLD virtual void save_register() |
| 455 | 455 | { |
| 456 | | save(NLNAME(m_state)); |
| 456 | save(NAME(m_state)); |
| 457 | 457 | netlist_owned_object_t::save_register(); |
| 458 | 458 | } |
| 459 | 459 | |
| r243832 | r243833 | |
| 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); |
| r243832 | r243833 | |
| 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; |
| r243832 | r243833 | |
| 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() |
| r243832 | r243833 | |
| 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 | |
| r243832 | r243833 | |
| 710 | 710 | */ |
| 711 | 711 | ATTR_COLD inline netlist_sig_t &Q_state_ptr() |
| 712 | 712 | { |
| 713 | | nl_assert(family() == LOGIC); |
| 713 | assert(family() == LOGIC); |
| 714 | 714 | return m_cur_Q; |
| 715 | 715 | } |
| 716 | 716 | |
| r243832 | r243833 | |
| 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 | | //nl_assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 742 | | nl_assert(family() == ANALOG); |
| 741 | //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 742 | 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 | | //nl_assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 749 | | nl_assert(family() == ANALOG); |
| 748 | //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 749 | assert(family() == ANALOG); |
| 750 | 750 | return m_cur_Analog; |
| 751 | 751 | } |
| 752 | 752 | |
| r243832 | r243833 | |
| 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; |
| r243832 | r243833 | |
| 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 | |
| r243832 | r243833 | |
| 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() |
| 885 | 885 | { |
| 886 | | save(NLNAME(m_param)); |
| 886 | save(NAME(m_param)); |
| 887 | 887 | netlist_param_t::save_register(); |
| 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 |
| r243832 | r243833 | |
| 905 | 905 | protected: |
| 906 | 906 | ATTR_COLD virtual void save_register() |
| 907 | 907 | { |
| 908 | | save(NLNAME(m_param)); |
| 908 | save(NAME(m_param)); |
| 909 | 909 | netlist_param_t::save_register(); |
| 910 | 910 | } |
| 911 | 911 | |
| r243832 | r243833 | |
| 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: |
| r243832 | r243833 | |
| 988 | 988 | |
| 989 | 989 | ATTR_HOT inline const netlist_sig_t INPLOGIC(const netlist_logic_input_t &inp) const |
| 990 | 990 | { |
| 991 | | nl_assert(inp.state() != netlist_input_t::STATE_INP_PASSIVE); |
| 991 | assert(inp.state() != netlist_input_t::STATE_INP_PASSIVE); |
| 992 | 992 | return inp.Q(); |
| 993 | 993 | } |
| 994 | 994 | |
| r243832 | r243833 | |
| 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 | } |
| r243832 | r243833 | |
| 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 | |
| r243832 | r243833 | |
| 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 | { |
| r243832 | r243833 | |
| 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 | { |
| r243832 | r243833 | |
| 1262 | 1262 | |
| 1263 | 1263 | ATTR_HOT inline netlist_logic_net_t & RESTRICT netlist_net_t::as_logic() |
| 1264 | 1264 | { |
| 1265 | | nl_assert(family() == LOGIC); |
| 1265 | assert(family() == LOGIC); |
| 1266 | 1266 | return static_cast<netlist_logic_net_t &>(*this); |
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | ATTR_HOT inline const netlist_logic_net_t & RESTRICT netlist_net_t::as_logic() const |
| 1270 | 1270 | { |
| 1271 | | nl_assert(family() == LOGIC); |
| 1271 | assert(family() == LOGIC); |
| 1272 | 1272 | return static_cast<const netlist_logic_net_t &>(*this); |
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | ATTR_HOT inline netlist_analog_net_t & RESTRICT netlist_net_t::as_analog() |
| 1276 | 1276 | { |
| 1277 | | nl_assert(family() == ANALOG); |
| 1277 | assert(family() == ANALOG); |
| 1278 | 1278 | return static_cast<netlist_analog_net_t &>(*this); |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | ATTR_HOT inline const netlist_analog_net_t & RESTRICT netlist_net_t::as_analog() const |
| 1282 | 1282 | { |
| 1283 | | nl_assert(family() == ANALOG); |
| 1283 | assert(family() == ANALOG); |
| 1284 | 1284 | return static_cast<const netlist_analog_net_t &>(*this); |
| 1285 | 1285 | } |
| 1286 | 1286 | |
| r243832 | r243833 | |
| 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 | { |
| r243832 | r243833 | |
| 1370 | 1370 | } |
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | |
| 1374 | // ----------------------------------------------------------------------------- |
| 1375 | // net_dev class factory |
| 1376 | // ----------------------------------------------------------------------------- |
| 1377 | |
| 1378 | class net_device_t_base_factory |
| 1379 | { |
| 1380 | NETLIST_PREVENT_COPYING(net_device_t_base_factory) |
| 1381 | public: |
| 1382 | ATTR_COLD net_device_t_base_factory(const pstring &name, const pstring &classname, |
| 1383 | const pstring &def_param) |
| 1384 | : m_name(name), m_classname(classname), m_def_param(def_param) |
| 1385 | {} |
| 1386 | |
| 1387 | ATTR_COLD virtual ~net_device_t_base_factory() {} |
| 1388 | |
| 1389 | ATTR_COLD virtual netlist_device_t *Create() const = 0; |
| 1390 | |
| 1391 | ATTR_COLD const pstring &name() const { return m_name; } |
| 1392 | ATTR_COLD const pstring &classname() const { return m_classname; } |
| 1393 | ATTR_COLD const pstring ¶m_desc() const { return m_def_param; } |
| 1394 | ATTR_COLD const nl_util::pstring_list term_param_list(); |
| 1395 | ATTR_COLD const nl_util::pstring_list def_params(); |
| 1396 | |
| 1397 | protected: |
| 1398 | pstring m_name; /* device name */ |
| 1399 | pstring m_classname; /* device class name */ |
| 1400 | pstring m_def_param; /* default parameter */ |
| 1401 | }; |
| 1402 | |
| 1403 | template <class C> |
| 1404 | class net_device_t_factory : public net_device_t_base_factory |
| 1405 | { |
| 1406 | NETLIST_PREVENT_COPYING(net_device_t_factory) |
| 1407 | public: |
| 1408 | ATTR_COLD net_device_t_factory(const pstring &name, const pstring &classname, |
| 1409 | const pstring &def_param) |
| 1410 | : net_device_t_base_factory(name, classname, def_param) { } |
| 1411 | |
| 1412 | ATTR_COLD netlist_device_t *Create() const |
| 1413 | { |
| 1414 | netlist_device_t *r = new C(); |
| 1415 | //r->init(setup, name); |
| 1416 | return r; |
| 1417 | } |
| 1418 | }; |
| 1419 | |
| 1420 | class netlist_factory_t |
| 1421 | { |
| 1422 | public: |
| 1423 | typedef plinearlist_t<net_device_t_base_factory *> list_t; |
| 1424 | |
| 1425 | ATTR_COLD netlist_factory_t(); |
| 1426 | ATTR_COLD ~netlist_factory_t(); |
| 1427 | |
| 1428 | ATTR_COLD void initialize(); |
| 1429 | |
| 1430 | template<class _C> |
| 1431 | ATTR_COLD void register_device(const pstring &name, const pstring &classname, |
| 1432 | const pstring &def_param) |
| 1433 | { |
| 1434 | m_list.add(new net_device_t_factory< _C >(name, classname, def_param) ); |
| 1435 | } |
| 1436 | |
| 1437 | ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const; |
| 1438 | ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const; |
| 1439 | ATTR_COLD net_device_t_base_factory * factory_by_name(const pstring &name, netlist_setup_t &setup) const; |
| 1440 | |
| 1441 | const list_t &list() { return m_list; } |
| 1442 | |
| 1443 | private: |
| 1444 | list_t m_list; |
| 1445 | |
| 1446 | }; |
| 1447 | |
| 1448 | |
| 1373 | 1449 | #endif /* NLBASE_H_ */ |
branches/kale/src/emu/netlist/nl_config.h
| r243832 | r243833 | |
| 10 | 10 | |
| 11 | 11 | /* FIXME: at some time, make it compile on it's own */ |
| 12 | 12 | |
| 13 | | #include "osdcore.h" |
| 14 | | #include "corealloc.h" |
| 15 | | #include <math.h> |
| 16 | | #include <exception> |
| 17 | | #include <typeinfo> |
| 13 | #include "emu.h" |
| 18 | 14 | |
| 19 | 15 | //============================================================ |
| 20 | 16 | // SETUP |
| r243832 | r243833 | |
| 49 | 45 | |
| 50 | 46 | #define NETLIST_GMIN_DEFAULT (1e-9) |
| 51 | 47 | |
| 52 | | //typedef double nl_double; |
| 53 | | |
| 54 | | #define nl_double double |
| 55 | | |
| 56 | 48 | //============================================================ |
| 57 | 49 | // DEBUGGING |
| 58 | 50 | //============================================================ |
| r243832 | r243833 | |
| 110 | 102 | #define end_timing(v) do { } while (0) |
| 111 | 103 | #endif |
| 112 | 104 | |
| 113 | | // this macro passes an item followed by a string version of itself as two consecutive parameters |
| 114 | | #define NLNAME(x) x, #x |
| 115 | 105 | |
| 116 | 106 | //============================================================ |
| 117 | | // Exceptions |
| 118 | | //============================================================ |
| 119 | | |
| 120 | | // emu_fatalerror is a generic fatal exception that provides an error string |
| 121 | | class nl_fatalerror : public std::exception |
| 122 | | { |
| 123 | | public: |
| 124 | | nl_fatalerror(const char *format, ...) ATTR_PRINTF(2,3) |
| 125 | | { |
| 126 | | char text[1024]; |
| 127 | | va_list ap; |
| 128 | | va_start(ap, format); |
| 129 | | vsprintf(text, format, ap); |
| 130 | | va_end(ap); |
| 131 | | osd_printf_error("%s\n", text); |
| 132 | | } |
| 133 | | nl_fatalerror(const char *format, va_list ap) |
| 134 | | { |
| 135 | | char text[1024]; |
| 136 | | vsprintf(text, format, ap); |
| 137 | | osd_printf_error("%s\n", text); |
| 138 | | } |
| 139 | | }; |
| 140 | | |
| 141 | | //============================================================ |
| 142 | | // Memory allocation |
| 143 | | //============================================================ |
| 144 | | |
| 145 | | #define nl_alloc(T, ...) global_alloc(T(__VA_ARGS__)) |
| 146 | | #define nl_alloc_array(T, N) global_alloc_array(T, N) |
| 147 | | |
| 148 | | #define nl_free(_ptr) global_free(_ptr) |
| 149 | | #define nl_free_array(_ptr) global_free_array(_ptr) |
| 150 | | |
| 151 | | |
| 152 | | //============================================================ |
| 153 | | // Asserts |
| 154 | | //============================================================ |
| 155 | | |
| 156 | | #ifdef MAME_DEBUG |
| 157 | | #define nl_assert(x) do { if (!(x)) throw nl_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0) |
| 158 | | #define nl_assert_always(x, msg) do { if (!(x)) throw nl_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0) |
| 159 | | #else |
| 160 | | #define nl_assert(x) do { } while (0) |
| 161 | | //#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0) |
| 162 | | #define nl_assert_always(x, msg) do { } while (0) |
| 163 | | #endif |
| 164 | | |
| 165 | | //============================================================ |
| 166 | 107 | // Compiling standalone |
| 167 | 108 | //============================================================ |
| 168 | 109 | |
| 169 | 110 | // Compiling without mame ? |
| 170 | 111 | |
| 171 | 112 | #ifndef ATTR_HOT |
| 172 | | #warning ATTR_HOT not defined |
| 113 | //#warning ATTR_HOT not defined |
| 173 | 114 | |
| 174 | 115 | // standard C includes |
| 175 | 116 | #include <math.h> |
| r243832 | r243833 | |
| 191 | 132 | #define UNEXPECTED |
| 192 | 133 | #define ATTR_UNUSED __attribute__((__unused__)) |
| 193 | 134 | |
| 135 | // this macro passes an item followed by a string version of itself as two consecutive parameters |
| 136 | #define NAME(x) x, #x |
| 137 | |
| 194 | 138 | /* 8-bit values */ |
| 195 | 139 | typedef unsigned char UINT8; |
| 196 | 140 | typedef signed char INT8; |
| r243832 | r243833 | |
| 216 | 160 | #endif |
| 217 | 161 | #endif |
| 218 | 162 | |
| 163 | #ifdef MAME_DEBUG |
| 164 | #define assert(x) do { if (!(x)) throw emu_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0) |
| 165 | #define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0) |
| 166 | #else |
| 167 | #define assert(x) do { } while (0) |
| 168 | //#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0) |
| 169 | #define assert_always(x, msg) do { } while (0) |
| 170 | #endif |
| 171 | |
| 219 | 172 | /* U64 and S64 are used to wrap long integer constants. */ |
| 220 | 173 | #if defined(__GNUC__) || defined(_MSC_VER) |
| 221 | 174 | #define U64(val) val##ULL |
branches/kale/src/emu/netlist/nl_factory.c
| r243832 | r243833 | |
| 1 | | // license:GPL-2.0+ |
| 2 | | // copyright-holders:Couriersud |
| 3 | | /*************************************************************************** |
| 4 | | |
| 5 | | nl_factory.c |
| 6 | | |
| 7 | | Discrete netlist implementation. |
| 8 | | |
| 9 | | **************************************************************************** |
| 10 | | |
| 11 | | Couriersud reserves the right to license the code under a less restrictive |
| 12 | | license going forward. |
| 13 | | |
| 14 | | Copyright Nicola Salmoria and the MAME team |
| 15 | | All rights reserved. |
| 16 | | |
| 17 | | Redistribution and use of this code or any derivative works are permitted |
| 18 | | provided that the following conditions are met: |
| 19 | | |
| 20 | | * Redistributions may not be sold, nor may they be used in a commercial |
| 21 | | product or activity. |
| 22 | | |
| 23 | | * Redistributions that are modified from the original source must include the |
| 24 | | complete source code, including the source code for all components used by a |
| 25 | | binary built from the modified sources. However, as a special exception, the |
| 26 | | source code distributed need not include anything that is normally distributed |
| 27 | | (in either source or binary form) with the major components (compiler, kernel, |
| 28 | | and so on) of the operating system on which the executable runs, unless that |
| 29 | | component itself accompanies the executable. |
| 30 | | |
| 31 | | * Redistributions must reproduce the above copyright notice, this list of |
| 32 | | conditions and the following disclaimer in the documentation and/or other |
| 33 | | materials provided with the distribution. |
| 34 | | |
| 35 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 36 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 37 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 38 | | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 39 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 40 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 41 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 42 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 43 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 44 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 45 | | POSSIBILITY OF SUCH DAMAGE. |
| 46 | | |
| 47 | | |
| 48 | | ****************************************************************************/ |
| 49 | | |
| 50 | | #include "nl_factory.h" |
| 51 | | #include "nl_setup.h" |
| 52 | | |
| 53 | | netlist_factory_t::netlist_factory_t() |
| 54 | | { |
| 55 | | } |
| 56 | | |
| 57 | | netlist_factory_t::~netlist_factory_t() |
| 58 | | { |
| 59 | | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 60 | | { |
| 61 | | net_device_t_base_factory *p = *e; |
| 62 | | global_free(p); |
| 63 | | } |
| 64 | | m_list.clear(); |
| 65 | | } |
| 66 | | |
| 67 | | netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const |
| 68 | | { |
| 69 | | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 70 | | { |
| 71 | | net_device_t_base_factory *p = *e; |
| 72 | | if (strcmp(p->classname(), classname) == 0) |
| 73 | | { |
| 74 | | netlist_device_t *ret = p->Create(); |
| 75 | | return ret; |
| 76 | | } |
| 77 | | p++; |
| 78 | | } |
| 79 | | setup.netlist().error("Class %s not found!\n", classname.cstr()); |
| 80 | | return NULL; // appease code analysis |
| 81 | | } |
| 82 | | |
| 83 | | netlist_device_t *netlist_factory_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const |
| 84 | | { |
| 85 | | net_device_t_base_factory *f = factory_by_name(name, setup); |
| 86 | | return f->Create(); |
| 87 | | } |
| 88 | | |
| 89 | | net_device_t_base_factory * netlist_factory_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const |
| 90 | | { |
| 91 | | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 92 | | { |
| 93 | | net_device_t_base_factory *p = *e; |
| 94 | | if (strcmp(p->name(), name) == 0) |
| 95 | | { |
| 96 | | return p; |
| 97 | | } |
| 98 | | p++; |
| 99 | | } |
| 100 | | setup.netlist().error("Class %s not found!\n", name.cstr()); |
| 101 | | return NULL; // appease code analysis |
| 102 | | } |
branches/kale/src/emu/ui/devopt.c
| r243832 | r243833 | |
| 1 | | /********************************************************************* |
| 2 | | |
| 3 | | ui/devopt.c |
| 4 | | |
| 5 | | Internal menu for the device configuration. |
| 6 | | |
| 7 | | Copyright Nicola Salmoria and the MAME Team. |
| 8 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | | |
| 10 | | *********************************************************************/ |
| 11 | | |
| 12 | | #include "emu.h" |
| 13 | | #include "ui/ui.h" |
| 14 | | #include "ui/devopt.h" |
| 15 | | |
| 16 | | /*------------------------------------------------- |
| 17 | | ui_device_config - handle the game information |
| 18 | | menu |
| 19 | | -------------------------------------------------*/ |
| 20 | | |
| 21 | | ui_menu_device_config::ui_menu_device_config(running_machine &machine, render_container *container, device_slot_interface *slot, device_slot_option *option) : ui_menu(machine, container) |
| 22 | | { |
| 23 | | astring tmp_tag; |
| 24 | | tmp_tag.cpy(slot->device().tag()).cat(":").cat(option->name()); |
| 25 | | m_option = option; |
| 26 | | m_owner = slot; |
| 27 | | m_mounted = false; |
| 28 | | |
| 29 | | device_iterator deviter(machine.config().root_device()); |
| 30 | | for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) |
| 31 | | { |
| 32 | | if (strcmp(device->tag(), tmp_tag.cstr()) == 0) |
| 33 | | { |
| 34 | | m_mounted = true; |
| 35 | | break; |
| 36 | | } |
| 37 | | } |
| 38 | | } |
| 39 | | |
| 40 | | void ui_menu_device_config::populate() |
| 41 | | { |
| 42 | | astring string; |
| 43 | | device_t *dev; |
| 44 | | |
| 45 | | string.printf("[This option is%s currently mounted in the running system]\n\n", m_mounted ? "" : " NOT"); |
| 46 | | string.catprintf("Option: %s\n", m_option->name()); |
| 47 | | |
| 48 | | dev = const_cast<machine_config &>(machine().config()).device_add(&machine().config().root_device(), m_option->name(), m_option->devtype(), 0); |
| 49 | | |
| 50 | | string.catprintf("Device: %s\n", dev->name()); |
| 51 | | if (!m_mounted) |
| 52 | | string.cat("\nIf you select this option, the following items will be enabled:\n"); |
| 53 | | else |
| 54 | | string.cat("\nThe selected option enables the following items:\n"); |
| 55 | | |
| 56 | | // loop over all CPUs |
| 57 | | execute_interface_iterator execiter(*dev); |
| 58 | | if (execiter.count() > 0) |
| 59 | | { |
| 60 | | string.cat("* CPU:\n"); |
| 61 | | tagmap_t<UINT8> exectags; |
| 62 | | for (device_execute_interface *exec = execiter.first(); exec != NULL; exec = execiter.next()) |
| 63 | | { |
| 64 | | if (exectags.add(exec->device().tag(), 1, FALSE) == TMERR_DUPLICATE) |
| 65 | | continue; |
| 66 | | |
| 67 | | // get cpu specific clock that takes internal multiplier/dividers into account |
| 68 | | int clock = exec->device().clock(); |
| 69 | | |
| 70 | | // count how many identical CPUs we have |
| 71 | | int count = 1; |
| 72 | | const char *name = exec->device().name(); |
| 73 | | execute_interface_iterator execinneriter(*dev); |
| 74 | | for (device_execute_interface *scan = execinneriter.first(); scan != NULL; scan = execinneriter.next()) |
| 75 | | { |
| 76 | | if (exec->device().type() == scan->device().type() && strcmp(name, scan->device().name()) == 0 && exec->device().clock() == scan->device().clock()) |
| 77 | | if (exectags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) |
| 78 | | count++; |
| 79 | | } |
| 80 | | |
| 81 | | // if more than one, prepend a #x in front of the CPU name |
| 82 | | if (count > 1) |
| 83 | | string.catprintf(" %d" UTF8_MULTIPLY, count); |
| 84 | | else |
| 85 | | string.cat(" "); |
| 86 | | string.cat(name); |
| 87 | | |
| 88 | | // display clock in kHz or MHz |
| 89 | | if (clock >= 1000000) |
| 90 | | string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000); |
| 91 | | else |
| 92 | | string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000); |
| 93 | | } |
| 94 | | } |
| 95 | | |
| 96 | | // display screen information |
| 97 | | screen_device_iterator scriter(*dev); |
| 98 | | if (scriter.count() > 0) |
| 99 | | { |
| 100 | | string.cat("* Video:\n"); |
| 101 | | for (screen_device *screen = scriter.first(); screen != NULL; screen = scriter.next()) |
| 102 | | { |
| 103 | | string.catprintf(" Screen '%s': ", screen->tag()); |
| 104 | | |
| 105 | | if (screen->screen_type() == SCREEN_TYPE_VECTOR) |
| 106 | | string.cat("Vector\n"); |
| 107 | | else |
| 108 | | { |
| 109 | | const rectangle &visarea = screen->visible_area(); |
| 110 | | |
| 111 | | string.catprintf("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n", |
| 112 | | visarea.width(), visarea.height(), |
| 113 | | (machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H", |
| 114 | | ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds)); |
| 115 | | } |
| 116 | | } |
| 117 | | } |
| 118 | | |
| 119 | | // loop over all sound chips |
| 120 | | sound_interface_iterator snditer(*dev); |
| 121 | | if (snditer.count() > 0) |
| 122 | | { |
| 123 | | string.cat("* Sound:\n"); |
| 124 | | tagmap_t<UINT8> soundtags; |
| 125 | | for (device_sound_interface *sound = snditer.first(); sound != NULL; sound = snditer.next()) |
| 126 | | { |
| 127 | | if (soundtags.add(sound->device().tag(), 1, FALSE) == TMERR_DUPLICATE) |
| 128 | | continue; |
| 129 | | |
| 130 | | // count how many identical sound chips we have |
| 131 | | int count = 1; |
| 132 | | sound_interface_iterator sndinneriter(*dev); |
| 133 | | for (device_sound_interface *scan = sndinneriter.first(); scan != NULL; scan = sndinneriter.next()) |
| 134 | | { |
| 135 | | if (sound->device().type() == scan->device().type() && sound->device().clock() == scan->device().clock()) |
| 136 | | if (soundtags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) |
| 137 | | count++; |
| 138 | | } |
| 139 | | // if more than one, prepend a #x in front of the CPU name |
| 140 | | if (count > 1) |
| 141 | | string.catprintf(" %d" UTF8_MULTIPLY, count); |
| 142 | | else |
| 143 | | string.cat(" "); |
| 144 | | string.cat(sound->device().name()); |
| 145 | | |
| 146 | | // display clock in kHz or MHz |
| 147 | | int clock = sound->device().clock(); |
| 148 | | if (clock >= 1000000) |
| 149 | | string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000); |
| 150 | | else if (clock != 0) |
| 151 | | string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000); |
| 152 | | else |
| 153 | | string.cat("\n"); |
| 154 | | } |
| 155 | | } |
| 156 | | |
| 157 | | int input = 0, input_mj = 0, input_hana = 0, input_gamble = 0, input_analog = 0, input_adjust = 0; |
| 158 | | int dips = 0, confs = 0; |
| 159 | | astring errors, dips_opt, confs_opt; |
| 160 | | ioport_list portlist; |
| 161 | | device_iterator iptiter(*dev); |
| 162 | | for (device_t *iptdev = iptiter.first(); iptdev != NULL; iptdev = iptiter.next()) |
| 163 | | portlist.append(*iptdev, errors); |
| 164 | | |
| 165 | | // check if the device adds inputs to the system |
| 166 | | for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) |
| 167 | | for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) |
| 168 | | { |
| 169 | | if (field->type() >= IPT_MAHJONG_FIRST && field->type() < IPT_MAHJONG_LAST) |
| 170 | | input_mj++; |
| 171 | | else if (field->type() >= IPT_HANAFUDA_FIRST && field->type() < IPT_HANAFUDA_LAST) |
| 172 | | input_hana++; |
| 173 | | else if (field->type() >= IPT_GAMBLING_FIRST && field->type() < IPT_GAMBLING_LAST) |
| 174 | | input_gamble++; |
| 175 | | else if (field->type() >= IPT_ANALOG_FIRST && field->type() < IPT_ANALOG_LAST) |
| 176 | | input_analog++; |
| 177 | | else if (field->type() == IPT_ADJUSTER) |
| 178 | | input_adjust++; |
| 179 | | else if (field->type() >= IPT_START1 && field->type() < IPT_UI_FIRST) |
| 180 | | input++; |
| 181 | | else if (field->type() == IPT_DIPSWITCH) |
| 182 | | { |
| 183 | | dips++; |
| 184 | | dips_opt.cat(" ").cat(field->name()); |
| 185 | | for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next()) |
| 186 | | { |
| 187 | | if (setting->value() == field->defvalue()) |
| 188 | | { |
| 189 | | dips_opt.catprintf(" [default: %s]\n", setting->name()); |
| 190 | | break; |
| 191 | | } |
| 192 | | } |
| 193 | | } |
| 194 | | else if (field->type() == IPT_CONFIG) |
| 195 | | { |
| 196 | | confs++; |
| 197 | | confs_opt.cat(" ").cat(field->name()); |
| 198 | | for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next()) |
| 199 | | { |
| 200 | | if (setting->value() == field->defvalue()) |
| 201 | | { |
| 202 | | confs_opt.catprintf(" [default: %s]\n", setting->name()); |
| 203 | | break; |
| 204 | | } |
| 205 | | } |
| 206 | | } |
| 207 | | } |
| 208 | | |
| 209 | | if (dips) |
| 210 | | string.cat("* Dispwitch settings:\n").cat(dips_opt); |
| 211 | | if (confs) |
| 212 | | string.cat("* Configuration settings:\n").cat(confs_opt); |
| 213 | | if (input + input_mj + input_hana + input_gamble + input_analog + input_adjust) |
| 214 | | string.cat("* Input device(s):\n"); |
| 215 | | if (input) |
| 216 | | string.catprintf(" Player inputs [%d inputs]\n", input); |
| 217 | | if (input_mj) |
| 218 | | string.catprintf(" Mahjong inputs [%d inputs]\n", input_mj); |
| 219 | | if (input_hana) |
| 220 | | string.catprintf(" Hanafuda inputs [%d inputs]\n", input_hana); |
| 221 | | if (input_gamble) |
| 222 | | string.catprintf(" Gambling inputs [%d inputs]\n", input_gamble); |
| 223 | | if (input_analog) |
| 224 | | string.catprintf(" Analog inputs [%d inputs]\n", input_analog); |
| 225 | | if (input_adjust) |
| 226 | | string.catprintf(" Adjuster inputs [%d inputs]\n", input_adjust); |
| 227 | | |
| 228 | | image_interface_iterator imgiter(*dev); |
| 229 | | if (imgiter.count() > 0) |
| 230 | | { |
| 231 | | string.cat("* Media Options:\n"); |
| 232 | | for (const device_image_interface *imagedev = imgiter.first(); imagedev != NULL; imagedev = imgiter.next()) |
| 233 | | string.catprintf(" %s [tag: %s]\n", imagedev->image_type_name(), imagedev->device().tag()); |
| 234 | | } |
| 235 | | |
| 236 | | slot_interface_iterator slotiter(*dev); |
| 237 | | if (slotiter.count() > 0) |
| 238 | | { |
| 239 | | string.cat("* Slot Options:\n"); |
| 240 | | for (const device_slot_interface *slot = slotiter.first(); slot != NULL; slot = slotiter.next()) |
| 241 | | string.catprintf(" %s [default: %s]\n", slot->device().tag(), slot->default_option() ? slot->default_option() : "----"); |
| 242 | | } |
| 243 | | |
| 244 | | if ((execiter.count() + scriter.count() + snditer.count() + imgiter.count() + slotiter.count() + input + input_mj + input_hana + input_gamble + input_analog + input_adjust) == 0) |
| 245 | | string.cat("[None]\n"); |
| 246 | | |
| 247 | | const_cast<machine_config &>(machine().config()).device_remove(&machine().config().root_device(), m_option->name()); |
| 248 | | item_append(string, NULL, MENU_FLAG_MULTILINE, NULL); |
| 249 | | } |
| 250 | | |
| 251 | | void ui_menu_device_config::handle() |
| 252 | | { |
| 253 | | /* process the menu */ |
| 254 | | process(0); |
| 255 | | } |
| 256 | | |
| 257 | | ui_menu_device_config::~ui_menu_device_config() |
| 258 | | { |
| 259 | | } |
branches/kale/src/emu/ui/filemngr.c
| r243832 | r243833 | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
| 62 | | void ui_menu_file_manager::fill_image_line(device_image_interface *img, astring &instance, astring &filename) |
| 63 | | { |
| 64 | | // get the image type/id |
| 65 | | instance.printf("%s (%s)", img->instance_name(), img->brief_instance_name()); |
| 66 | | |
| 67 | | // get the base name |
| 68 | | if (img->basename() != NULL) |
| 69 | | { |
| 70 | | filename.cpy(img->basename()); |
| 71 | | |
| 72 | | // if the image has been loaded through softlist, also show the loaded part |
| 73 | | if (img->part_entry() != NULL) |
| 74 | | { |
| 75 | | const software_part *tmp = img->part_entry(); |
| 76 | | if (tmp->name() != NULL) |
| 77 | | { |
| 78 | | filename.cat(" ("); |
| 79 | | filename.cat(tmp->name()); |
| 80 | | // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it |
| 81 | | if (img->get_feature("part_id") != NULL) |
| 82 | | { |
| 83 | | filename.cat(": "); |
| 84 | | filename.cat(img->get_feature("part_id")); |
| 85 | | } |
| 86 | | filename.cat(")"); |
| 87 | | } |
| 88 | | } |
| 89 | | } |
| 90 | | else |
| 91 | | filename.cpy("---"); |
| 92 | | } |
| 93 | | |
| 94 | 62 | //------------------------------------------------- |
| 95 | 63 | // populate |
| 96 | 64 | //------------------------------------------------- |
| 97 | 65 | |
| 98 | 66 | void ui_menu_file_manager::populate() |
| 99 | 67 | { |
| 100 | | astring buffer, tmp_inst, tmp_name; |
| 101 | | bool first_entry = true; |
| 102 | | astring prev_owner; |
| 68 | astring buffer; |
| 69 | bool first = true; |
| 103 | 70 | |
| 104 | 71 | // cycle through all devices for this system |
| 105 | | device_iterator iter(machine().root_device()); |
| 106 | | tagmap_t<UINT8> devtags; |
| 107 | | for (device_t *dev = iter.first(); dev != NULL; dev = iter.next()) |
| 72 | image_interface_iterator iter(machine().root_device()); |
| 73 | for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) |
| 108 | 74 | { |
| 109 | | bool tag_appended = false; |
| 110 | | if (devtags.add(dev->tag(), 1, FALSE) == TMERR_DUPLICATE) |
| 111 | | continue; |
| 75 | if (first) |
| 76 | first = false; |
| 77 | else |
| 78 | item_append("", NULL, MENU_FLAG_DISABLE, NULL); |
| 112 | 79 | |
| 113 | | // check whether it owns an image interface |
| 114 | | image_interface_iterator subiter(*dev); |
| 115 | | if (subiter.count() > 0) |
| 116 | | { |
| 117 | | // if so, cycle through all its image interfaces |
| 118 | | image_interface_iterator subiter(*dev); |
| 119 | | for (device_image_interface *scan = subiter.first(); scan != NULL; scan = subiter.next()) |
| 80 | // get the image type/id |
| 81 | buffer.printf("%s (%s)", image->instance_name(), image->brief_instance_name()); |
| 82 | item_append(buffer, "", MENU_FLAG_DISABLE, NULL); |
| 83 | item_append("Device", image->device().tag(), MENU_FLAG_DISABLE, NULL); |
| 84 | |
| 85 | // get the base name |
| 86 | if (image->basename() != NULL) |
| 87 | { |
| 88 | buffer.cpy(image->basename()); |
| 89 | |
| 90 | // if the image has been loaded through softlist, also show the loaded part |
| 91 | if (image->part_entry() != NULL) |
| 120 | 92 | { |
| 121 | | // if it is a children device, and not something further down the device tree, we want it in the menu! |
| 122 | | if (strcmp(scan->device().owner()->tag(), dev->tag()) == 0) |
| 123 | | if (devtags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) |
| 93 | const software_part *tmp = image->part_entry(); |
| 94 | if (tmp->name() != NULL) |
| 95 | { |
| 96 | buffer.cat(" ("); |
| 97 | buffer.cat(tmp->name()); |
| 98 | // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it |
| 99 | if (image->get_feature("part_id") != NULL) |
| 124 | 100 | { |
| 125 | | // check whether we already had some devices with the same owner: if not, output the owner tag! |
| 126 | | if (!tag_appended) |
| 127 | | { |
| 128 | | if (first_entry) |
| 129 | | first_entry = false; |
| 130 | | else |
| 131 | | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 132 | | buffer.printf("[root%s]", dev->tag()); |
| 133 | | item_append(buffer, NULL, 0, NULL); |
| 134 | | tag_appended = true; |
| 135 | | } |
| 136 | | // finally, append the image interface to the menu |
| 137 | | fill_image_line(scan, tmp_inst, tmp_name); |
| 138 | | item_append(tmp_inst, tmp_name, 0, (void *) scan); |
| 101 | buffer.cat(": "); |
| 102 | buffer.cat(image->get_feature("part_id")); |
| 139 | 103 | } |
| 104 | buffer.cat(")"); |
| 105 | } |
| 140 | 106 | } |
| 141 | 107 | } |
| 108 | else |
| 109 | buffer.cpy("---"); |
| 110 | |
| 111 | // record the menu item |
| 112 | item_append("Mounted File", buffer, 0, (void *) image); |
| 142 | 113 | } |
| 143 | 114 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 144 | 115 | item_append("Reset", NULL, 0, (void *)1); |
branches/kale/src/mame/audio/mario.c
| r243832 | r243833 | |
| 2 | 2 | #include "cpu/z80/z80.h" |
| 3 | 3 | #include "cpu/mcs48/mcs48.h" |
| 4 | 4 | #include "sound/ay8910.h" |
| 5 | #include "sound/discrete.h" |
| 5 | 6 | |
| 6 | 7 | #include "includes/mario.h" |
| 7 | 8 | |
| r243832 | r243833 | |
| 38 | 39 | #define I8035_P1_W_AH(M,B,D) I8035_P1_W(M,ACTIVEHIGH_PORT_BIT(I8035_P1_R(M),B,(D))) |
| 39 | 40 | #define I8035_P2_W_AH(M,B,D) I8035_P2_W(M,ACTIVEHIGH_PORT_BIT(I8035_P2_R(M),B,(D))) |
| 40 | 41 | |
| 41 | | |
| 42 | | #if !OLD_SOUND |
| 43 | | |
| 44 | | /* ---------------------------------------------------------------------- */ |
| 45 | | /* mario sound */ |
| 46 | | /* ---------------------------------------------------------------------- */ |
| 47 | | static NETLIST_START(nl_mario_snd0) |
| 48 | | |
| 49 | | RES(R17, RES_K(27)) /* 20 according to parts list */ |
| 50 | | /* 27 verified, 30K in schematics */ |
| 51 | | CAP(C14, CAP_U(4.7)) /* verified */ |
| 52 | | |
| 53 | | TTL_74123(2H_A) |
| 54 | | NET_C(2H_A.VCC, V5) |
| 55 | | NET_C(2H_A.GND, GND) |
| 56 | | NET_C(SOUND0.Q, 2H_A.B) |
| 57 | | NET_C(GND, 2H_A.A) |
| 58 | | NET_C(2H_A.CLRQ, ttlhigh) /* NOT IN SCHEMATICS */ |
| 59 | | DIODE(D1, "1N4148") /* FIXME: try to identify */ |
| 60 | | TTL_7404_INVERT(1H_A, 2H_A.QQ) |
| 61 | | NET_C(R17.1, V5) |
| 62 | | NET_C(R17.2, D1.A, C14.1) |
| 63 | | NET_C(D1.K, 2H_A.RC) |
| 64 | | NET_C(C14.2, 2H_A.C) |
| 65 | | |
| 66 | | RES(R6, RES_K(4.7)) /* verified */ |
| 67 | | CAP(C3, CAP_U(10)) /* verified */ |
| 68 | | |
| 69 | | NET_C(1H_A.Q, R6.1) |
| 70 | | NET_C(R6.2, C3.1, 1J_A.FC) |
| 71 | | NET_C(R6.2, 2J_A.FC) |
| 72 | | NET_C(C3.2, GND) |
| 73 | | |
| 74 | | //#define MR_C6 CAP_N(3.9) /* verified */ |
| 75 | | |
| 76 | | SN74LS629(1J_A, CAP_N(3.9)) |
| 77 | | NET_C(1J_A.RNG, V5) |
| 78 | | NET_C(1J_A.ENQ, ttllow) |
| 79 | | NET_C(GND, 1J_A.GND) |
| 80 | | |
| 81 | | //#define MR_C17 CAP_N(22) /* verified */ |
| 82 | | |
| 83 | | SN74LS629(2J_A, CAP_N(22)) |
| 84 | | NET_C(2J_A.RNG, V5) |
| 85 | | NET_C(2J_A.ENQ, ttllow) |
| 86 | | NET_C(GND, 2J_A.GND) |
| 87 | | |
| 88 | | TTL_7486_XOR(1K_A, 1J_A.Y, 2J_A.Y) |
| 89 | | TTL_7408_AND(2K_A, 2H_A.Q, 1K_A) |
| 90 | | NETLIST_END() |
| 91 | | |
| 92 | | /* ---------------------------------------------------------------------- */ |
| 93 | | /* skid sound */ |
| 94 | | /* ---------------------------------------------------------------------- */ |
| 95 | | |
| 96 | | // FIXME: Diodes are 1S953 |
| 97 | | static NETLIST_START(nl_mario_snd7) |
| 98 | | |
| 99 | | RES(R61, RES_K(47)) |
| 100 | | CAP(C41, CAP_U(4.7)) /* verified */ |
| 101 | | |
| 102 | | TTL_74123(4L_A) |
| 103 | | NET_C(4L_A.VCC, V5) |
| 104 | | NET_C(4L_A.GND, GND) |
| 105 | | NET_C(SOUND7.Q, 4L_A.B) |
| 106 | | NET_C(GND, 4L_A.A) |
| 107 | | NET_C(4L_A.CLRQ, ttlhigh) /* NOT IN SCHEMATICS */ |
| 108 | | DIODE(D10, "1N4148") /* FIXME: try to identify */ |
| 109 | | TTL_7404_INVERT(4J_A, 4L_A.Q) |
| 110 | | NET_C(R61.1, V5) |
| 111 | | NET_C(R61.2, D10.A, C41.1) |
| 112 | | NET_C(D10.K, 4L_A.RC) |
| 113 | | NET_C(C41.2, 4L_A.C) |
| 114 | | |
| 115 | | RES(R65, RES_K(10)) |
| 116 | | CAP(C44, CAP_U(3.3)) /* verified */ |
| 117 | | |
| 118 | | SN74LS629(4K_A, CAP_U(0.022)) |
| 119 | | NET_C(4K_A.RNG, V5) |
| 120 | | NET_C(4K_A.ENQ, ttllow) |
| 121 | | NET_C(GND, 4K_A.GND) |
| 122 | | NET_C(R65.1, 4J_A.Q) |
| 123 | | NET_C(R65.2, 4K_A.FC, C44.1) |
| 124 | | NET_C(C44.2, GND) |
| 125 | | |
| 126 | | CD_4020(3H, 4K_B.Y, ttllow, V5, GND) |
| 127 | | TTL_7404_INVERT(4J_B, 3H.Q12) |
| 128 | | |
| 129 | | RES(R64, RES_K(20)) |
| 130 | | CAP(C43, CAP_U(3.3)) /* verified */ |
| 131 | | |
| 132 | | SN74LS629(4K_B, CAP_U(0.0047)) |
| 133 | | NET_C(4K_B.RNG, V5) |
| 134 | | NET_C(4K_B.ENQ, ttllow) |
| 135 | | NET_C(GND, 4K_B.GND) |
| 136 | | NET_C(R64.1, 4J_B.Q) |
| 137 | | NET_C(R64.2, 4K_B.FC, C43.1) |
| 138 | | NET_C(C43.2, GND) |
| 139 | | |
| 140 | | TTL_7486_XOR(1K_C, 3H.Q4, 4K_A.Y) |
| 141 | | TTL_7408_AND(2K_C, 4L_A.Q, 1K_C) |
| 142 | | |
| 143 | | NETLIST_END() |
| 144 | | |
| 145 | | /* ---------------------------------------------------------------------- */ |
| 146 | | /* DAC sound */ |
| 147 | | /* ---------------------------------------------------------------------- */ |
| 148 | | static NETLIST_START(nl_mario_dac) |
| 149 | | RES(R34, RES_M(2)) |
| 150 | | RES(R35, RES_M(1)) |
| 151 | | RES(R36, RES_M(1.8)) |
| 152 | | LM3900(3M_1) |
| 153 | | NET_C(3M_1.VM, GND) |
| 154 | | NET_C(3M_1.VP, V5) |
| 155 | | |
| 156 | | NET_C(DAC.VOUT, R34.1) |
| 157 | | NET_C(3M_1.MINUS, R34.2, R35.2) |
| 158 | | NET_C(3M_1.OUT, R35.1) |
| 159 | | NET_C(3M_1.PLUS, R36.1) |
| 160 | | NET_C(R36.2, GND) |
| 161 | | |
| 162 | | RES(R21, RES_M(1.8)) |
| 163 | | RES(R23, RES_K(10)) |
| 164 | | RES(R25, RES_K(10)) |
| 165 | | RES(R37, RES_K(750)) |
| 166 | | RES(R38, RES_K(360)) |
| 167 | | RES(R39, RES_K(750)) |
| 168 | | |
| 169 | | CAP(C18, CAP_P(100)) |
| 170 | | CAP(C19, CAP_U(10)) |
| 171 | | CAP(C20, CAP_U(1)) |
| 172 | | CAP(C30, CAP_P(100)) |
| 173 | | |
| 174 | | LM3900(3M_2) |
| 175 | | NET_C(3M_2.VM, GND) |
| 176 | | NET_C(3M_2.VP, V5) |
| 177 | | |
| 178 | | NET_C(R35.1, C20.1) |
| 179 | | NET_C(C20.2, R37.1) |
| 180 | | NET_C(R37.2, R38.2, C18.1, R39.2) |
| 181 | | |
| 182 | | NET_C(C18.2, GND) |
| 183 | | NET_C(R38.1, C30.2, 3M_2.MINUS) |
| 184 | | NET_C(3M_2.OUT, R39.1, C30.1) |
| 185 | | |
| 186 | | NET_C(R21.1, 3M_2.PLUS) |
| 187 | | NET_C(R21.2, C19.1, R25.2, R23.1) |
| 188 | | NET_C(C19.2, R23.2, GND) |
| 189 | | NET_C(R25.1, V5) |
| 190 | | NETLIST_END() |
| 191 | | |
| 192 | | static NETLIST_START(nl_mario) |
| 193 | | |
| 194 | | /* Standard stuff */ |
| 195 | | |
| 196 | | SOLVER(Solver, 48000) |
| 197 | | PARAM(Solver.ACCURACY, 1e-8) |
| 198 | | PARAM(Solver.SOR_FACTOR, 1.0) |
| 199 | | PARAM(Solver.GS_THRESHOLD, 5) |
| 200 | | PARAM(Solver.GS_LOOPS, 4) |
| 201 | | //PARAM(Solver.LTE, 5e-2) // Default is not enough for paddle control |
| 202 | | PARAM(Solver.DYNAMIC_TS, 0) |
| 203 | | ANALOG_INPUT(V5, 5) |
| 204 | | |
| 205 | | TTL_INPUT(SOUND0, 1) |
| 206 | | INCLUDE(nl_mario_snd0) |
| 207 | | |
| 208 | | TTL_INPUT(SOUND7, 1) |
| 209 | | INCLUDE(nl_mario_snd7) |
| 210 | | |
| 211 | | R2R_DAC(DAC, 3.4, 10000.0, 8) |
| 212 | | NET_C(DAC.VGND, GND) |
| 213 | | |
| 214 | | INCLUDE(nl_mario_dac) |
| 215 | | |
| 216 | | /* ---------------------------------------------------------------------- */ |
| 217 | | /* mixing */ |
| 218 | | /* ---------------------------------------------------------------------- */ |
| 219 | | |
| 220 | | RES(R20, RES_K(22)) /* verified */ |
| 221 | | RES(R19, RES_K(22)) /* verified */ |
| 222 | | RES(R40, RES_K(22)) /* verified */ |
| 223 | | RES(R41, RES_K(100)) /* verified */ |
| 224 | | CAP(C31, CAP_U(0.022)) /* */ |
| 225 | | |
| 226 | | NET_C(2K_A.Q, R20.1) |
| 227 | | NET_C(GND, R19.1) //FIXME |
| 228 | | NET_C(2K_C.Q, R41.1) |
| 229 | | |
| 230 | | #if 1 |
| 231 | | RES(DUM, RES_K(22)) |
| 232 | | NET_C(R39.1, DUM.1) |
| 233 | | NET_C(DUM.2, GND) |
| 234 | | FRONTIER(front1, R39.1, R40.1) |
| 235 | | #else |
| 236 | | NET_C(R39.1, R40.1) |
| 237 | | #endif |
| 238 | | |
| 239 | | NET_C(R20.2, R19.2, R40.2, R41.2, C31.1) |
| 240 | | NET_C(C31.2, GND) |
| 241 | | |
| 242 | | CAP(C32, CAP_U(1)) /* verified */ |
| 243 | | RES(R42, RES_K(43)) /* verified */ |
| 244 | | RES(R43, RES_K(100)) /* verified */ |
| 245 | | |
| 246 | | NET_C(C31.1, C32.1) |
| 247 | | NET_C(C32.2, R42.1, R43.2, Q10.B) |
| 248 | | //NET_C(C32.2, R42.1, R43.2) |
| 249 | | NET_C(R43.1, V5) |
| 250 | | NET_C(R42.2, GND) |
| 251 | | #if 1 |
| 252 | | RES(R63, RES_K(1)) /* */ |
| 253 | | RES(R62, 150) /* */ |
| 254 | | |
| 255 | | QBJT_EB(Q10, "2SC1815") |
| 256 | | |
| 257 | | NET_C(R62.2, GND) |
| 258 | | NET_C(R62.1, Q10.E) |
| 259 | | |
| 260 | | NET_C(R63.1, V5) |
| 261 | | NET_C(R63.2, Q10.C) |
| 262 | | |
| 263 | | CAP(C42, CAP_U(0.1)) |
| 264 | | CAP(C47, CAP_U(4.7)) |
| 265 | | RES(VR1, RES_K(10)) |
| 266 | | |
| 267 | | NET_C(C42.1, C47.1, R62.1) |
| 268 | | NET_C(C42.2, GND) |
| 269 | | NET_C(C47.2, VR1.1) |
| 270 | | NET_C(VR1.2, GND) |
| 271 | | #endif |
| 272 | | /* ---------------------------------------------------------------------- */ |
| 273 | | /* Output */ |
| 274 | | /* ---------------------------------------------------------------------- */ |
| 275 | | |
| 276 | | RES(ROUT, 1000000) |
| 277 | | |
| 278 | | //NET_C(Q10.C, ROUT.1) |
| 279 | | //NET_C(R43.2, ROUT.1) |
| 280 | | NET_C(VR1.1, ROUT.1) |
| 281 | | |
| 282 | | NET_C(GND, ROUT.2) |
| 283 | | |
| 284 | | NETLIST_END() |
| 285 | | |
| 286 | | #else |
| 287 | 42 | /**************************************************************** |
| 288 | 43 | * |
| 289 | 44 | * Discrete Sound defines |
| r243832 | r243833 | |
| 635 | 390 | DISCRETE_TASK_END() |
| 636 | 391 | |
| 637 | 392 | DISCRETE_SOUND_END |
| 638 | | #endif |
| 393 | |
| 639 | 394 | /**************************************************************** |
| 640 | 395 | * |
| 641 | 396 | * EA / Banking |
| r243832 | r243833 | |
| 743 | 498 | |
| 744 | 499 | WRITE8_MEMBER(mario_state::mario_sh_sound_w) |
| 745 | 500 | { |
| 746 | | #if OLD_SOUND |
| 747 | 501 | m_discrete->write(space, DS_DAC, data); |
| 748 | | #else |
| 749 | | m_audio_dac->write(data); |
| 750 | | #endif |
| 751 | 502 | } |
| 752 | 503 | |
| 753 | 504 | WRITE8_MEMBER(mario_state::mario_sh_p1_w) |
| r243832 | r243833 | |
| 787 | 538 | /* Mario running sample */ |
| 788 | 539 | WRITE8_MEMBER(mario_state::mario_sh1_w) |
| 789 | 540 | { |
| 790 | | #if OLD_SOUND |
| 791 | 541 | m_discrete->write(space, DS_SOUND0_INP, 0); |
| 792 | | #else |
| 793 | | m_audio_snd0->write(data); |
| 794 | | #endif |
| 795 | 542 | } |
| 796 | 543 | |
| 797 | 544 | /* Luigi running sample */ |
| 798 | 545 | WRITE8_MEMBER(mario_state::mario_sh2_w) |
| 799 | 546 | { |
| 800 | | #if OLD_SOUND |
| 801 | 547 | m_discrete->write(space, DS_SOUND1_INP, 0); |
| 802 | | #endif |
| 803 | 548 | } |
| 804 | 549 | |
| 805 | 550 | /* Misc samples */ |
| r243832 | r243833 | |
| 832 | 577 | I8035_P1_W_AH(space, 3, data & 1); |
| 833 | 578 | break; |
| 834 | 579 | case 7: /* skid */ |
| 835 | | #if OLD_SOUND |
| 836 | 580 | machine().device<discrete_device>("discrete")->write(space, DS_SOUND7_INP, data & 1); |
| 837 | | #else |
| 838 | | m_audio_snd7->write((data & 1) ^ 1); |
| 839 | | #endif |
| 840 | 581 | break; |
| 841 | 582 | } |
| 842 | 583 | } |
| r243832 | r243833 | |
| 885 | 626 | MCFG_CPU_IO_MAP(mario_sound_io_map) |
| 886 | 627 | |
| 887 | 628 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 888 | | |
| 889 | | #if OLD_SOUND |
| 890 | 629 | MCFG_SOUND_ADD("discrete", DISCRETE, 0) |
| 891 | 630 | MCFG_DISCRETE_INTF(mario) |
| 892 | 631 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1) |
| 893 | | #else |
| 894 | | MCFG_SOUND_ADD("snd_nl", NETLIST_SOUND, 48000) |
| 895 | | MCFG_NETLIST_SETUP(nl_mario) |
| 896 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 897 | 632 | |
| 898 | | MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd0", "SOUND0.IN", 0, 1) |
| 899 | | MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd7", "SOUND7.IN", 0, 1) |
| 900 | | MCFG_NETLIST_LOGIC_INPUT("snd_nl", "dac", "DAC.VAL", 0, 255) |
| 901 | | |
| 902 | | MCFG_NETLIST_STREAM_OUTPUT("snd_nl", 0, "ROUT.1") |
| 903 | | MCFG_NETLIST_ANALOG_MULT_OFFSET(150000.0, 0.0) |
| 904 | | #endif |
| 905 | | |
| 906 | 633 | MACHINE_CONFIG_END |
| 907 | 634 | |
| 908 | 635 | MACHINE_CONFIG_FRAGMENT( masao_audio ) |
branches/kale/src/mame/drivers/aleck64.c
| r243832 | r243833 | |
| 103 | 103 | JAPAN |
| 104 | 104 | |
| 105 | 105 | |
| 106 | On bootup, they also mention 'T.L.S' (Temporary Landing System), which seems |
| 107 | to be the hardware system, designed by Arika Co. Ltd. |
| 106 | 108 | |
| 107 | 109 | |
| 108 | 110 | PCB Layout |
| r243832 | r243833 | |
| 183 | 185 | DECLARE_DRIVER_INIT(aleck64); |
| 184 | 186 | DECLARE_WRITE32_MEMBER(aleck_dips_w); |
| 185 | 187 | DECLARE_READ32_MEMBER(aleck_dips_r); |
| 186 | | DECLARE_READ16_MEMBER(e90_prot_r); |
| 187 | | DECLARE_WRITE16_MEMBER(e90_prot_w); |
| 188 | 188 | private: |
| 189 | 189 | UINT32 m_dip_read_offset; |
| 190 | 190 | }; |
| r243832 | r243833 | |
| 311 | 311 | AM_RANGE(0x1fc00000, 0x1fc007bf) AM_ROM AM_REGION("user1", 0) // PIF ROM |
| 312 | 312 | AM_RANGE(0x1fc007c0, 0x1fc007ff) AM_DEVREADWRITE("rcp", n64_periphs, pif_ram_r, pif_ram_w) |
| 313 | 313 | |
| 314 | | AM_RANGE(0xc0000000, 0xc07fffff) AM_RAM // SDRAM, Aleck 64 specific |
| 314 | /* |
| 315 | Surely this should mirror main ram? srmvs crashes, and |
| 316 | vivdolls overwrites it's memory test code if it does mirror |
| 317 | */ |
| 318 | AM_RANGE(0xc0000000, 0xc07fffff) AM_RAM |
| 315 | 319 | |
| 316 | 320 | AM_RANGE(0xc0800000, 0xc0800fff) AM_READWRITE(aleck_dips_r,aleck_dips_w) |
| 317 | | ADDRESS_MAP_END |
| 321 | AM_RANGE(0xd0000000, 0xd00fffff) AM_RAM // mtetrisc, write only, mirror? |
| 318 | 322 | |
| 319 | | /* |
| 320 | | E90 protection handlers |
| 321 | | */ |
| 322 | | |
| 323 | | READ16_MEMBER(aleck64_state::e90_prot_r) |
| 324 | | { |
| 325 | | // offset 0 $800 = status ready, active high |
| 326 | | return 0; |
| 327 | | } |
| 328 | | |
| 329 | | WRITE16_MEMBER(aleck64_state::e90_prot_w) |
| 330 | | { |
| 331 | | switch(offset*2) |
| 332 | | { |
| 333 | | case 0x16: |
| 334 | | if(data != 6 && data != 7) |
| 335 | | printf("! %04x %04x %08x\n",offset*2,data,mem_mask); |
| 336 | | |
| 337 | | if(data & 1) // 0 -> 1 transition |
| 338 | | { |
| 339 | | //for(int i=0;i<0x1000;i+=4) |
| 340 | | // space.write_dword(0x007502f4+i,space.read_dword(0xd0000000+i)); |
| 341 | | } |
| 342 | | break; |
| 343 | | //0x1e bit 0 probably enables the chip |
| 344 | | default: |
| 345 | | printf("%04x %04x %08x\n",offset*2,data,mem_mask); |
| 346 | | break; |
| 347 | | } |
| 348 | | } |
| 349 | | |
| 350 | | static ADDRESS_MAP_START( e90_map, AS_PROGRAM, 32, aleck64_state ) |
| 351 | | AM_IMPORT_FROM( n64_map ) |
| 352 | | AM_RANGE(0xd0000000, 0xd0000fff) AM_RAM // x/y offsets |
| 353 | | AM_RANGE(0xd0010000, 0xd0010fff) AM_RAM // RGB555 palette |
| 354 | | AM_RANGE(0xd0030000, 0xd003001f) AM_READWRITE16(e90_prot_r, e90_prot_w,0xffffffff) |
| 355 | 323 | ADDRESS_MAP_END |
| 356 | 324 | |
| 357 | 325 | static ADDRESS_MAP_START( rsp_map, AS_PROGRAM, 32, aleck64_state ) |
| r243832 | r243833 | |
| 383 | 351 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(1) |
| 384 | 352 | |
| 385 | 353 | PORT_START("P1_ANALOG_Y") |
| 386 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(1) PORT_REVERSE |
| 354 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0xff,0x00) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(1) |
| 387 | 355 | |
| 388 | 356 | PORT_START("P2") |
| 389 | 357 | PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) // Button A |
| r243832 | r243833 | |
| 406 | 374 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(2) |
| 407 | 375 | |
| 408 | 376 | PORT_START("P2_ANALOG_Y") |
| 409 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(2) PORT_REVERSE |
| 377 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0xff,0x00) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(2) |
| 410 | 378 | |
| 411 | 379 | PORT_START("IN0") |
| 412 | 380 | PORT_DIPNAME( 0x80000000, 0x80000000, "DIPSW1 #8" ) PORT_DIPLOCATION("SW1:8") |
| r243832 | r243833 | |
| 489 | 457 | PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 490 | 458 | PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 491 | 459 | PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(2) |
| 460 | |
| 461 | PORT_MODIFY("P1_ANALOG_Y") |
| 462 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_REVERSE PORT_PLAYER(1) |
| 463 | |
| 464 | PORT_MODIFY("P2_ANALOG_Y") |
| 465 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_REVERSE PORT_PLAYER(2) |
| 466 | |
| 492 | 467 | INPUT_PORTS_END |
| 493 | 468 | |
| 494 | 469 | static INPUT_PORTS_START( mtetrisc ) |
| r243832 | r243833 | |
| 873 | 848 | MCFG_N64_PERIPHS_ADD("rcp"); |
| 874 | 849 | MACHINE_CONFIG_END |
| 875 | 850 | |
| 876 | | static MACHINE_CONFIG_DERIVED( a64_e90, aleck64 ) |
| 877 | | MCFG_CPU_MODIFY("maincpu") |
| 878 | | MCFG_CPU_PROGRAM_MAP(e90_map) |
| 879 | | MACHINE_CONFIG_END |
| 880 | | |
| 881 | 851 | DRIVER_INIT_MEMBER(aleck64_state,aleck64) |
| 882 | 852 | { |
| 883 | 853 | UINT8 *rom = memregion("user2")->base(); |
| r243832 | r243833 | |
| 1112 | 1082 | |
| 1113 | 1083 | // games |
| 1114 | 1084 | GAME( 1998, 11beat, aleck64, aleck64, 11beat, aleck64_state, aleck64, ROT0, "Hudson", "Eleven Beat", GAME_NOT_WORKING ) // crashes at kick off / during attract with DRC |
| 1115 | | GAME( 1998, mtetrisc, aleck64, a64_e90, mtetrisc, aleck64_state, aleck64, ROT0, "Capcom", "Magical Tetris Challenge (981009 Japan)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS ) |
| 1085 | GAME( 1998, mtetrisc, aleck64, aleck64, mtetrisc, aleck64_state, aleck64, ROT0, "Capcom", "Magical Tetris Challenge (981009 Japan)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS ) |
| 1116 | 1086 | GAME( 1998, starsldr, aleck64, aleck64, starsldr, aleck64_state, aleck64, ROT0, "Hudson / Seta", "Star Soldier: Vanishing Earth", GAME_IMPERFECT_GRAPHICS ) |
| 1117 | 1087 | GAME( 1998, vivdolls, aleck64, aleck64, aleck64, aleck64_state, aleck64, ROT0, "Visco", "Vivid Dolls", GAME_IMPERFECT_GRAPHICS ) |
| 1118 | 1088 | GAME( 1999, srmvs, aleck64, aleck64, srmvs, aleck64_state, aleck64, ROT0, "Seta", "Super Real Mahjong VS", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS ) |
branches/kale/src/mame/drivers/peplus.c
| r243832 | r243833 | |
| 3687 | 3687 | ROM_REGION( 0x020000, "gfx1", 0 ) |
| 3688 | 3688 | ROM_LOAD( "mro-cg2153.u72", 0x00000, 0x8000, CRC(004c9c8e) SHA1(ec3fa9d2c658de59e722d9979513d6b0c71d5742) ) /* 05/01/95 @ IGT L95-1123 */ |
| 3689 | 3689 | ROM_LOAD( "mgo-cg2153.u73", 0x08000, 0x8000, CRC(e6843b35) SHA1(2d5219a3cb054ce8b470797c0496c7e24e94ed81) ) |
| 3690 | | ROM_LOAD( "mbo-cg2153.u74", 0x10000, 0x8000, CRC(e3e28611) SHA1(d040f1df6203dc0bd6a79a391fb90fb930f8dd1a) ) /* Custom Arizona Charlie's Casino card backs */ |
| 3690 | ROM_LOAD( "mbo-cg2153.u74", 0x10000, 0x8000, CRC(e3e28611) SHA1(d040f1df6203dc0bd6a79a391fb90fb930f8dd1a) ) /* Custom Arizona Charlie's Casino graphics */ |
| 3691 | 3691 | ROM_LOAD( "mxo-cg2153.u75", 0x18000, 0x8000, CRC(3ae44f7e) SHA1(00d625b60bffef6ce622cb50a3aa93b92131f578) ) |
| 3692 | 3692 | |
| 3693 | 3693 | ROM_REGION( 0x100, "proms", 0 ) |
| r243832 | r243833 | |
| 4772 | 4772 | Four of a Kind Bonus Poker |
| 4773 | 4773 | Deuces Wild Poker |
| 4774 | 4774 | |
| 4775 | | Also uses a Dallas (Maxim) DS1216 SmartWatch RAM for RTC (Real Time Clock) functions |
| 4776 | | |
| 4777 | 4775 | Came out of an IGT machine with belly glass calling it Montana Choice |
| 4778 | 4776 | */ |
| 4779 | 4777 | ROM_REGION( 0x10000, "maincpu", 0 ) |
| r243832 | r243833 | |
| 5393 | 5391 | ROM_LOAD( "x000055p.u66", 0x00000, 0x10000, CRC(e06819df) SHA1(36590c4588b8036908e63714fbb3e77d23e60eae) ) /* Deuces Wild Poker */ |
| 5394 | 5392 | |
| 5395 | 5393 | ROM_REGION( 0x020000, "gfx1", 0 ) |
| 5396 | | ROM_LOAD( "mro-cg2291.u77", 0x00000, 0x8000, CRC(db4e491c) SHA1(e371e7b236962a0f30640c683d3a0a302c51aee9) ) /* Custom The Orleans card backs */ |
| 5394 | ROM_LOAD( "mro-cg2291.u77", 0x00000, 0x8000, CRC(db4e491c) SHA1(e371e7b236962a0f30640c683d3a0a302c51aee9) ) /* Custom The Orleans graphics */ |
| 5397 | 5395 | ROM_LOAD( "mgo-cg2291.u78", 0x08000, 0x8000, CRC(17bb35f8) SHA1(ba9e8aa3ff42b17c7be6ee46c70db22d8e60e52c) ) /* Compatible with most "standard" game sets */ |
| 5398 | 5396 | ROM_LOAD( "mbo-cg2291.u79", 0x10000, 0x8000, CRC(de1036e4) SHA1(774bbcda301754dc4a606974248847a2264c3827) ) |
| 5399 | 5397 | ROM_LOAD( "mxo-cg2291.u80", 0x18000, 0x8000, CRC(7049403c) SHA1(3a29a00fb8dfdb30dba757c1536151827ea09068) ) |
| r243832 | r243833 | |
| 5418 | 5416 | ROM_LOAD( "x000055p.u66", 0x00000, 0x10000, CRC(e06819df) SHA1(36590c4588b8036908e63714fbb3e77d23e60eae) ) /* Deuces Wild Poker */ |
| 5419 | 5417 | |
| 5420 | 5418 | ROM_REGION( 0x020000, "gfx1", 0 ) |
| 5421 | | ROM_LOAD( "mro-cg2399.u72", 0x00000, 0x8000, CRC(0424f4ba) SHA1(c8b192a6f63c8c9937cb3923d27b9ba2c39823cd) ) /* Custom The Fun Ships card backs */ |
| 5419 | ROM_LOAD( "mro-cg2399.u72", 0x00000, 0x8000, CRC(0424f4ba) SHA1(c8b192a6f63c8c9937cb3923d27b9ba2c39823cd) ) /* Custom The Fun Ships graphics */ |
| 5422 | 5420 | ROM_LOAD( "mgo-cg2399.u73", 0x08000, 0x8000, CRC(5848a2fa) SHA1(4173a473016b7a776d2b59bf3ded0be35bd43721) ) |
| 5423 | 5421 | ROM_LOAD( "mbo-cg2399.u74", 0x10000, 0x8000, CRC(5c3e16f6) SHA1(a4aa457f239527bffa6472e0d6f9d836f796b326) ) |
| 5424 | 5422 | ROM_LOAD( "mxo-cg2399.u75", 0x18000, 0x8000, CRC(bd7669d5) SHA1(4343a9764fd563e2e1cdd8558f2f53f77006b159) ) |
| r243832 | r243833 | |
| 5443 | 5441 | ROM_LOAD( "x000055p.u66", 0x00000, 0x10000, CRC(e06819df) SHA1(36590c4588b8036908e63714fbb3e77d23e60eae) ) /* Deuces Wild Poker */ |
| 5444 | 5442 | |
| 5445 | 5443 | ROM_REGION( 0x020000, "gfx1", 0 ) |
| 5446 | | ROM_LOAD( "mro-cg2374.u72", 0x00000, 0x8000, CRC(ceeb714d) SHA1(6de908d04bcaa243195943affa9ad0d725de5c81) ) /* Custom Horseshoe Casino card backs */ |
| 5447 | | ROM_LOAD( "mgo-cg2374.u73", 0x08000, 0x8000, CRC(d0fabad5) SHA1(438ebe074fa3eaa3073ef042f481449f416d0665) ) |
| 5448 | | ROM_LOAD( "mbo-cg2374.u74", 0x10000, 0x8000, CRC(9a0fbc8d) SHA1(aa39f47cbeaf8218fd2d753c9a350e9eab5df5d3) ) |
| 5449 | | ROM_LOAD( "mxo-cg2374.u75", 0x18000, 0x8000, CRC(99814562) SHA1(2d8e132f4cc4edd06332c0327927219513b22832) ) |
| 5444 | ROM_LOAD( "mro-cg2185.u77", 0x00000, 0x8000, CRC(7e64bd1a) SHA1(e988a380ee58078bf5bdc7747e83aed1393cfad8) ) /* 07/10/95 @ IGT L95-1506 */ |
| 5445 | ROM_LOAD( "mgo-cg2185.u78", 0x08000, 0x8000, CRC(d4127893) SHA1(75039c45ba6fd171a66876c91abc3191c7feddfc) ) |
| 5446 | ROM_LOAD( "mbo-cg2185.u79", 0x10000, 0x8000, CRC(17dba955) SHA1(5f77379c88839b3a04e235e4fb0120c77e17b60e) ) |
| 5447 | ROM_LOAD( "mxo-cg2185.u80", 0x18000, 0x8000, CRC(583eb3b1) SHA1(4a2952424969917fb1594698a779fe5a1e99bff5) ) |
| 5450 | 5448 | |
| 5451 | 5449 | ROM_REGION( 0x200, "proms", 0 ) |
| 5452 | | ROM_LOAD( "capx2374.u43", 0x0000, 0x0200, CRC(f922e1b8) SHA1(4aa5291c59431c022dc0561a6e3b38209f60286a) ) |
| 5450 | ROM_LOAD( "capx1321.u43", 0x0000, 0x0200, CRC(4b57569f) SHA1(fa29c0f627e7ce79951ec6dadec114864144f37d) ) |
| 5453 | 5451 | ROM_END |
| 5454 | 5452 | |
| 5455 | 5453 | ROM_START( pex0055pd ) /* Superboard : Deuces Wild Poker (X000055P+XP000035) */ |
| r243832 | r243833 | |
| 7940 | 7938 | ROM_LOAD( "x002374p.u66", 0x00000, 0x10000, CRC(fc4b6c8d) SHA1(b101f9042bd54dbfdeed4c7a3acf3798096f6857) ) /* Super Aces Poker */ |
| 7941 | 7939 | |
| 7942 | 7940 | ROM_REGION( 0x020000, "gfx1", 0 ) |
| 7943 | | ROM_LOAD( "mro-cg2324.u77", 0x00000, 0x8000, CRC(6eceef42) SHA1(a2ddd2a3290c41e510f483c6b633fe0002694d0b) ) |
| 7944 | | ROM_LOAD( "mgo-cg2324.u78", 0x08000, 0x8000, CRC(26d0acbe) SHA1(09a9127deb88185cd5b748bac657461eadb2f48f) ) |
| 7945 | | ROM_LOAD( "mbo-cg2324.u79", 0x10000, 0x8000, CRC(47baee32) SHA1(d8af09022ccb5fc06aa3aa4c200a734b66cbee00) ) |
| 7946 | | ROM_LOAD( "mxo-cg2324.u80", 0x18000, 0x8000, CRC(60449fc0) SHA1(251d1e04786b70c1d2bc7b02f3b69cd58ac76398) ) |
| 7941 | ROM_LOAD( "mro-cg2374.u72", 0x00000, 0x8000, CRC(ceeb714d) SHA1(6de908d04bcaa243195943affa9ad0d725de5c81) ) /* Custom Horseshoe Casino card backs */ |
| 7942 | ROM_LOAD( "mgo-cg2374.u73", 0x08000, 0x8000, CRC(d0fabad5) SHA1(438ebe074fa3eaa3073ef042f481449f416d0665) ) |
| 7943 | ROM_LOAD( "mbo-cg2374.u74", 0x10000, 0x8000, CRC(9a0fbc8d) SHA1(aa39f47cbeaf8218fd2d753c9a350e9eab5df5d3) ) |
| 7944 | ROM_LOAD( "mxo-cg2374.u75", 0x18000, 0x8000, CRC(99814562) SHA1(2d8e132f4cc4edd06332c0327927219513b22832) ) |
| 7947 | 7945 | |
| 7948 | 7946 | ROM_REGION( 0x200, "proms", 0 ) |
| 7949 | | ROM_LOAD( "capx1321.u43", 0x0000, 0x0200, CRC(4b57569f) SHA1(fa29c0f627e7ce79951ec6dadec114864144f37d) ) |
| 7947 | ROM_LOAD( "cap2374.u43", 0x0000, 0x0200, CRC(f922e1b8) SHA1(4aa5291c59431c022dc0561a6e3b38209f60286a) ) |
| 7950 | 7948 | ROM_END |
| 7951 | 7949 | |
| 7952 | 7950 | ROM_START( pex2377p ) /* Superboard : Super Double Bonus Poker (X002377P+XP000112) */ |
| r243832 | r243833 | |
| 9265 | 9263 | GAMEL(1995, pex0055p, 0, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X000055P+XP000019) Deuces Wild Poker", 0, layout_pe_poker ) |
| 9266 | 9264 | GAMEL(1995, pex0055pa, pex0055p, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X000055P+XP000022) Deuces Wild Poker (The Orleans)", 0, layout_pe_poker ) |
| 9267 | 9265 | GAMEL(1995, pex0055pb, pex0055p, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X000055P+XP000023) Deuces Wild Poker (The Fun Ships)", 0, layout_pe_poker ) |
| 9268 | | GAMEL(1995, pex0055pc, pex0055p, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X000055P+XP000028) Deuces Wild Poker (Horseshoe)", 0, layout_pe_poker ) |
| 9266 | GAMEL(1995, pex0055pc, pex0055p, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X000055P+XP000028) Deuces Wild Poker", 0, layout_pe_poker ) |
| 9269 | 9267 | GAMEL(1995, pex0055pd, pex0055p, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X000055P+XP000035) Deuces Wild Poker", 0, layout_pe_poker ) |
| 9270 | 9268 | GAMEL(1995, pex0055pe, pex0055p, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X000055P+XP000038) Deuces Wild Poker", 0, layout_pe_poker ) |
| 9271 | 9269 | GAMEL(1995, pex0055pf, pex0055p, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X000055P+XP000040) Deuces Wild Poker", 0, layout_pe_poker ) |
| r243832 | r243833 | |
| 9363 | 9361 | GAMEL(1995, pex2308p, 0, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X002308P+XP000112) Triple Double Bonus Poker", 0, layout_pe_poker ) |
| 9364 | 9362 | GAMEL(1995, pex2310p, 0, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X002310P+XP000112) Triple Double Bonus Poker", 0, layout_pe_poker ) |
| 9365 | 9363 | GAMEL(1995, pex2314p, 0, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X002314P+XP000112) Triple Bonus Poker Plus", 0, layout_pe_poker ) |
| 9366 | | GAMEL(1995, pex2374p, 0, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X002374P+XP000112) Super Aces Poker", 0, layout_pe_poker ) |
| 9364 | GAMEL(1995, pex2374p, 0, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X002374P+XP000112) Super Aces Poker (Horseshoe)", 0, layout_pe_poker ) |
| 9367 | 9365 | GAMEL(1995, pex2377p, 0, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X002377P+XP000112) Super Double Bonus Poker", 0, layout_pe_poker ) |
| 9368 | 9366 | GAMEL(1995, pex2419p, 0, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X002419P+XP000064) Deuces Wild Bonus Poker - French", 0, layout_pe_poker ) |
| 9369 | 9367 | GAMEL(1995, pex2420p, 0, peplus, peplus_poker, peplus_state, peplussb, ROT0, "IGT - International Game Technology", "Player's Edge Plus (X002420P+XP000064) Deuces Wild Bonus Poker - French", 0, layout_pe_poker ) |
branches/kale/src/mame/drivers/snowbros.c
| r243832 | r243833 | |
| 185 | 185 | if (ACCESSING_BITS_0_7) soundlatch_byte_w(space,0,data & 0xff); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | READ16_MEMBER(snowbros_state::toto_read) |
| 189 | { |
| 190 | int pc = space.device().safe_pc(); |
| 191 | if ((pc!= 0x3f010) && (pc!= 0x38008)) printf("toto prot %08x %04x\n", pc, mem_mask); |
| 192 | return 0x0700; |
| 193 | } |
| 194 | |
| 188 | 195 | /* Snow Bros Memory Map */ |
| 189 | 196 | |
| 190 | 197 | static ADDRESS_MAP_START( snowbros_map, AS_PROGRAM, 16, snowbros_state ) |
| r243832 | r243833 | |
| 1955 | 1962 | ROM_LOAD16_BYTE( "wb09.bin", 0x60001, 0x10000, CRC(9be718ca) SHA1(5c195e4f13efbdb229201d2408d018861bf389cc) ) |
| 1956 | 1963 | ROM_END |
| 1957 | 1964 | |
| 1965 | ROM_START( toto ) |
| 1966 | ROM_REGION( 0x40000, "maincpu", 0 ) |
| 1967 | ROM_LOAD16_BYTE( "u60.5j", 0x00000, 0x20000, CRC(39203792) SHA1(4c8d560be02a514cbf91774c7a0b4a95cf573356) ) |
| 1968 | ROM_LOAD16_BYTE( "u51.4j", 0x00001, 0x20000, CRC(7b846cd4) SHA1(04aa0bbaab4303fb08dff52d5515f7e764f1be6d)) |
| 1969 | |
| 1970 | ROM_REGION( 0x10000, "soundcpu", 0 ) /* 64k for z80 sound code */ |
| 1971 | ROM_LOAD( "u46.4c", 0x0000, 0x8000, CRC(77b1ef42) SHA1(75e3c8c2b687669cc56f972dd7375dab5185859c) ) |
| 1972 | |
| 1973 | ROM_REGION( 0x80000, "gfx1", 0 ) |
| 1974 | ROM_LOAD( "u107.8k", 0x00000, 0x20000, CRC(4486153b) SHA1(a6dc0c17bf2328ab725bce4aaa0a413a42129fb0) ) |
| 1975 | ROM_LOAD( "u108.8l", 0x20000, 0x20000, CRC(3286cf5f) SHA1(133366b0e10ab86111247cbedf329e8e3a7f2148) ) |
| 1976 | ROM_LOAD( "u109.8m", 0x40000, 0x20000, CRC(464d7251) SHA1(f03ee54e9301ea87de4171cecdbad4a5e17929c4) ) |
| 1977 | ROM_LOAD( "u110.8n", 0x60000, 0x20000, CRC(7dea56df) SHA1(7e7b9238837c6f4221cff416a2de21723d2c9272) ) |
| 1978 | ROM_END |
| 1979 | |
| 1958 | 1980 | /* Barko */ |
| 1959 | 1981 | |
| 1960 | 1982 | ROM_START( honeydol ) |
| r243832 | r243833 | |
| 2866 | 2888 | |
| 2867 | 2889 | |
| 2868 | 2890 | |
| 2891 | DRIVER_INIT_MEMBER(snowbros_state,toto) |
| 2892 | { |
| 2893 | // every single rom has bits 0x10 and 0x08 swapped |
| 2894 | UINT8 *src = memregion("maincpu")->base(); |
| 2895 | int len = memregion("maincpu")->bytes(); |
| 2896 | |
| 2897 | for (int i = 0; i < len; i++) |
| 2898 | { |
| 2899 | src[i] = BITSWAP8(src[i], 7, 6, 5, 3, 4, 2, 1, 0); |
| 2900 | } |
| 2901 | |
| 2902 | src = memregion("gfx1")->base(); |
| 2903 | len = memregion("gfx1")->bytes(); |
| 2904 | |
| 2905 | for (int i = 0; i < len; i++) |
| 2906 | { |
| 2907 | src[i] = BITSWAP8(src[i], 7, 6, 5, 3, 4, 2, 1, 0); |
| 2908 | } |
| 2909 | |
| 2910 | src = memregion("soundcpu")->base(); |
| 2911 | len = memregion("soundcpu")->bytes(); |
| 2912 | |
| 2913 | for (int i = 0; i < len; i++) |
| 2914 | { |
| 2915 | src[i] = BITSWAP8(src[i], 7, 6, 5, 3, 4, 2, 1, 0); |
| 2916 | } |
| 2917 | |
| 2918 | // protection? (just return 0x07) |
| 2919 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x500006, 0x500007, read16_delegate(FUNC(snowbros_state::toto_read),this)); |
| 2920 | } |
| 2921 | |
| 2922 | |
| 2923 | |
| 2869 | 2924 | GAME( 1990, snowbros, 0, snowbros, snowbros, driver_device, 0, ROT0, "Toaplan", "Snow Bros. - Nick & Tom (set 1)", 0 ) |
| 2870 | 2925 | GAME( 1990, snowbrosa, snowbros, snowbros, snowbros, driver_device, 0, ROT0, "Toaplan", "Snow Bros. - Nick & Tom (set 2)", 0 ) |
| 2871 | 2926 | GAME( 1990, snowbrosb, snowbros, snowbros, snowbros, driver_device, 0, ROT0, "Toaplan", "Snow Bros. - Nick & Tom (set 3)", 0 ) |
| r243832 | r243833 | |
| 2875 | 2930 | GAME( 1990, wintbob, snowbros, wintbob, snowbros, driver_device, 0, ROT0, "bootleg (Sakowa Project Korea)", "The Winter Bobble (bootleg of Snow Bros.)", 0 ) |
| 2876 | 2931 | GAME( 1990, snowbroswb,snowbros, wintbob, snowbros, driver_device, 0, ROT0, "bootleg", "Snow Bros. - Nick & Tom (The Winter Bobble hardware bootleg)", 0 ) // this was probably unhacked back from the more common Winter Bobble to make it look more original |
| 2877 | 2932 | |
| 2933 | GAME( 1996, toto, 0, snowbros, snowbros, snowbros_state, toto, ROT0, "SoftClub", "Come Back Toto", 0 ) // modified from 'snowbros' code |
| 2934 | |
| 2878 | 2935 | // none of the games below are on genuine SnowBros hardware, but they clone the functionality of it. |
| 2879 | 2936 | |
| 2880 | 2937 | // SemiCom / Jeil titles are protected, a dumb MCU copies code into RAM at startup, some also check for a specific return value from an address on startup. |
branches/kale/src/mame/drivers/stfight.c
| r243832 | r243833 | |
| 247 | 247 | #include "cpu/z80/z80.h" |
| 248 | 248 | #include "cpu/m6805/m6805.h" |
| 249 | 249 | #include "sound/2203intf.h" |
| 250 | #include "sound/msm5205.h" |
| 250 | 251 | #include "includes/stfight.h" |
| 251 | 252 | |
| 252 | 253 | static ADDRESS_MAP_START( cpu1_map, AS_PROGRAM, 8, stfight_state ) |
| r243832 | r243833 | |
| 1036 | 1037 | ROM_END |
| 1037 | 1038 | |
| 1038 | 1039 | // Note: Marked GAME_IMPERFECT_SOUND due to YM2203 clock issue |
| 1039 | | GAME( 1986, empcity, 0, stfight, stfight, stfight_state, empcity, ROT0, "Seibu Kaihatsu", "Empire City: 1931 (bootleg?)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
| 1040 | | GAME( 1986, empcityu, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Taito / Romstar license)", "Empire City: 1931 (US)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) // different title logo |
| 1041 | | GAME( 1986, empcityj, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Taito license)", "Empire City: 1931 (Japan)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
| 1042 | | GAME( 1986, empcityi, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Eurobed license)", "Empire City: 1931 (Italy)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
| 1043 | | GAME( 1986, stfight, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Tuning license)", "Street Fight (Germany)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
| 1044 | | GAME( 1986, stfighta, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu", "Street Fight (bootleg?)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
| 1040 | GAME( 1986, empcity, 0, stfight, stfight, stfight_state, empcity, ROT0, "Seibu Kaihatsu", "Empire City: 1931 (bootleg?)", GAME_IMPERFECT_SOUND ) |
| 1041 | GAME( 1986, empcityu, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Taito / Romstar license)", "Empire City: 1931 (US)", GAME_IMPERFECT_SOUND ) // different title logo |
| 1042 | GAME( 1986, empcityj, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Taito license)", "Empire City: 1931 (Japan)", GAME_IMPERFECT_SOUND ) |
| 1043 | GAME( 1986, empcityi, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Eurobed license)", "Empire City: 1931 (Italy)", GAME_IMPERFECT_SOUND ) |
| 1044 | GAME( 1986, stfight, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Tuning license)", "Street Fight (Germany)", GAME_IMPERFECT_SOUND ) |
| 1045 | GAME( 1986, stfighta, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu", "Street Fight (bootleg?)", GAME_IMPERFECT_SOUND ) |
| 1045 | 1046 | /* Cross Shooter runs on a slightly modified PCB, with a different text tilemap and gfx blobs (see also cshooter.c) */ |
| 1046 | | GAME( 1987, cshooter, 0, cshooter,cshooter, stfight_state, cshooter,ROT270,"Seibu Kaihatsu (Taito license)", "Cross Shooter (not encrypted)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) |
| 1047 | GAME( 1987, cshooter, 0, cshooter,cshooter, stfight_state, cshooter,ROT270,"Seibu Kaihatsu (Taito license)", "Cross Shooter (not encrypted)", GAME_NOT_WORKING ) |
branches/kale/src/mame/drivers/strnskil.c
| r243832 | r243833 | |
| 22 | 22 | #include "sound/sn76496.h" |
| 23 | 23 | #include "includes/strnskil.h" |
| 24 | 24 | |
| 25 | | |
| 26 | | |
| 27 | | void strnskil_state::machine_start() |
| 28 | | { |
| 29 | | save_item(NAME(m_scrl_ctrl)); |
| 30 | | save_item(NAME(m_irq_source)); |
| 31 | | } |
| 32 | | |
| 33 | 25 | /****************************************************************************/ |
| 34 | 26 | |
| 35 | 27 | READ8_MEMBER(strnskil_state::strnskil_d800_r) |
| r243832 | r243833 | |
| 541 | 533 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd80d, 0xd80d, write8_delegate(FUNC(strnskil_state::protection_w),this)); |
| 542 | 534 | } |
| 543 | 535 | |
| 544 | | GAME( 1984, strnskil, 0, strnskil, strnskil, driver_device, 0, ROT0, "Sun Electronics", "Strength & Skill", GAME_SUPPORTS_SAVE ) |
| 545 | | GAME( 1984, guiness, strnskil, strnskil, strnskil, driver_device, 0, ROT0, "Sun Electronics", "The Guiness (Japan)", GAME_SUPPORTS_SAVE ) |
| 546 | | GAME( 1984, banbam, 0, banbam, banbam, strnskil_state, banbam, ROT0, "Sun Electronics", "BanBam", GAME_UNEMULATED_PROTECTION | GAME_SUPPORTS_SAVE ) |
| 547 | | GAME( 1984, pettanp, banbam, strnskil, banbam, strnskil_state, pettanp, ROT0, "Sun Electronics", "Pettan Pyuu (Japan)", GAME_UNEMULATED_PROTECTION | GAME_SUPPORTS_SAVE ) |
| 536 | GAME( 1984, strnskil, 0, strnskil, strnskil, driver_device, 0, ROT0, "Sun Electronics", "Strength & Skill", 0 ) |
| 537 | GAME( 1984, guiness, strnskil, strnskil, strnskil, driver_device, 0, ROT0, "Sun Electronics", "The Guiness (Japan)", 0 ) |
| 538 | GAME( 1984, banbam, 0, banbam, banbam, strnskil_state, banbam, ROT0, "Sun Electronics", "BanBam", GAME_UNEMULATED_PROTECTION ) |
| 539 | GAME( 1984, pettanp, banbam, strnskil, banbam, strnskil_state, pettanp, ROT0, "Sun Electronics", "Pettan Pyuu (Japan)", GAME_UNEMULATED_PROTECTION ) |
branches/kale/src/mame/includes/stfight.h
| r243832 | r243833 | |
| 10 | 10 | |
| 11 | 11 | stfight_state(const machine_config &mconfig, device_type type, const char *tag) |
| 12 | 12 | : driver_device(mconfig, type, tag), |
| 13 | m_text_char_ram(*this, "text_char_ram"), |
| 14 | m_text_attr_ram(*this, "text_attr_ram"), |
| 15 | m_tx_vram(*this, "tx_vram"), |
| 16 | m_vh_latch_ram(*this, "vh_latch_ram"), |
| 17 | m_sprite_ram(*this, "sprite_ram"), |
| 13 | 18 | m_maincpu(*this, "maincpu"), |
| 14 | 19 | m_audiocpu(*this, "audiocpu"), |
| 15 | 20 | m_mcu(*this, "mcu"), |
| 16 | 21 | m_msm(*this, "msm"), |
| 17 | 22 | m_gfxdecode(*this, "gfxdecode"), |
| 18 | | m_palette(*this, "palette"), |
| 19 | | m_text_char_ram(*this, "text_char_ram"), |
| 20 | | m_text_attr_ram(*this, "text_attr_ram"), |
| 21 | | m_tx_vram(*this, "tx_vram"), |
| 22 | | m_vh_latch_ram(*this, "vh_latch_ram"), |
| 23 | | m_sprite_ram(*this, "sprite_ram") { } |
| 23 | m_palette(*this, "palette") { } |
| 24 | 24 | |
| 25 | optional_shared_ptr<UINT8> m_text_char_ram; |
| 26 | optional_shared_ptr<UINT8> m_text_attr_ram; |
| 27 | optional_shared_ptr<UINT8> m_tx_vram; |
| 28 | required_shared_ptr<UINT8> m_vh_latch_ram; |
| 29 | required_shared_ptr<UINT8> m_sprite_ram; |
| 25 | 30 | required_device<cpu_device> m_maincpu; |
| 26 | 31 | required_device<cpu_device> m_audiocpu; |
| 27 | 32 | required_device<cpu_device> m_mcu; |
| 28 | 33 | required_device<msm5205_device> m_msm; |
| 29 | 34 | required_device<gfxdecode_device> m_gfxdecode; |
| 30 | 35 | required_device<palette_device> m_palette; |
| 31 | | |
| 32 | | optional_shared_ptr<UINT8> m_text_char_ram; |
| 33 | | optional_shared_ptr<UINT8> m_text_attr_ram; |
| 34 | | optional_shared_ptr<UINT8> m_tx_vram; |
| 35 | | required_shared_ptr<UINT8> m_vh_latch_ram; |
| 36 | | required_shared_ptr<UINT8> m_sprite_ram; |
| 37 | 36 | |
| 38 | 37 | UINT8 *m_decrypt; |
| 39 | 38 | UINT8 m_fm_data; |
| r243832 | r243833 | |
| 80 | 79 | |
| 81 | 80 | DECLARE_VIDEO_START(stfight); |
| 82 | 81 | DECLARE_VIDEO_START(cshooter); |
| 83 | | virtual void machine_start(); |
| 84 | 82 | virtual void machine_reset(); |
| 85 | 83 | DECLARE_PALETTE_INIT(stfight); |
| 86 | 84 | UINT32 screen_update_stfight(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| r243832 | r243833 | |
| 108 | 106 | UINT8 m_portB_out, m_portB_in; |
| 109 | 107 | UINT8 m_portC_out, m_portC_in; |
| 110 | 108 | UINT8 m_ddrA, m_ddrB, m_ddrC; |
| 109 | UINT8 m_from_main, m_main_sent; |
| 111 | 110 | |
| 112 | 111 | protected: |
| 113 | 112 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
branches/kale/src/mame/includes/stlforce.h
| r243832 | r243833 | |
| 6 | 6 | public: |
| 7 | 7 | stlforce_state(const machine_config &mconfig, device_type type, const char *tag) |
| 8 | 8 | : driver_device(mconfig, type, tag), |
| 9 | | m_maincpu(*this, "maincpu"), |
| 10 | | m_oki(*this, "oki"), |
| 11 | | m_eeprom(*this, "eeprom"), |
| 12 | | m_gfxdecode(*this, "gfxdecode"), |
| 13 | | m_palette(*this, "palette"), |
| 14 | 9 | m_bg_videoram(*this, "bg_videoram"), |
| 15 | 10 | m_mlow_videoram(*this, "mlow_videoram"), |
| 16 | 11 | m_mhigh_videoram(*this, "mhigh_videoram"), |
| r243832 | r243833 | |
| 19 | 14 | m_mlow_scrollram(*this, "mlow_scrollram"), |
| 20 | 15 | m_mhigh_scrollram(*this, "mhigh_scrollram"), |
| 21 | 16 | m_vidattrram(*this, "vidattrram"), |
| 22 | | m_spriteram(*this, "spriteram") { } |
| 17 | m_spriteram(*this, "spriteram"), |
| 18 | m_maincpu(*this, "maincpu"), |
| 19 | m_oki(*this, "oki"), |
| 20 | m_eeprom(*this, "eeprom"), |
| 21 | m_gfxdecode(*this, "gfxdecode"), |
| 22 | m_palette(*this, "palette") { } |
| 23 | 23 | |
| 24 | | required_device<cpu_device> m_maincpu; |
| 25 | | required_device<okim6295_device> m_oki; |
| 26 | | required_device<eeprom_serial_93cxx_device> m_eeprom; |
| 27 | | required_device<gfxdecode_device> m_gfxdecode; |
| 28 | | required_device<palette_device> m_palette; |
| 24 | tilemap_t *m_bg_tilemap; |
| 25 | tilemap_t *m_mlow_tilemap; |
| 26 | tilemap_t *m_mhigh_tilemap; |
| 27 | tilemap_t *m_tx_tilemap; |
| 29 | 28 | |
| 30 | 29 | required_shared_ptr<UINT16> m_bg_videoram; |
| 31 | 30 | required_shared_ptr<UINT16> m_mlow_videoram; |
| r243832 | r243833 | |
| 35 | 34 | required_shared_ptr<UINT16> m_mlow_scrollram; |
| 36 | 35 | required_shared_ptr<UINT16> m_mhigh_scrollram; |
| 37 | 36 | required_shared_ptr<UINT16> m_vidattrram; |
| 37 | |
| 38 | 38 | required_shared_ptr<UINT16> m_spriteram; |
| 39 | | |
| 40 | | tilemap_t *m_bg_tilemap; |
| 41 | | tilemap_t *m_mlow_tilemap; |
| 42 | | tilemap_t *m_mhigh_tilemap; |
| 43 | | tilemap_t *m_tx_tilemap; |
| 44 | 39 | |
| 45 | 40 | int m_sprxoffs; |
| 46 | | |
| 47 | 41 | DECLARE_WRITE16_MEMBER(stlforce_bg_videoram_w); |
| 48 | 42 | DECLARE_WRITE16_MEMBER(stlforce_mlow_videoram_w); |
| 49 | 43 | DECLARE_WRITE16_MEMBER(stlforce_mhigh_videoram_w); |
| 50 | 44 | DECLARE_WRITE16_MEMBER(stlforce_tx_videoram_w); |
| 51 | 45 | DECLARE_WRITE16_MEMBER(eeprom_w); |
| 52 | 46 | DECLARE_WRITE16_MEMBER(oki_bank_w); |
| 53 | | |
| 54 | 47 | DECLARE_DRIVER_INIT(twinbrat); |
| 55 | 48 | DECLARE_DRIVER_INIT(stlforce); |
| 56 | | |
| 57 | 49 | TILE_GET_INFO_MEMBER(get_stlforce_bg_tile_info); |
| 58 | 50 | TILE_GET_INFO_MEMBER(get_stlforce_mlow_tile_info); |
| 59 | 51 | TILE_GET_INFO_MEMBER(get_stlforce_mhigh_tile_info); |
| 60 | 52 | TILE_GET_INFO_MEMBER(get_stlforce_tx_tile_info); |
| 61 | | |
| 62 | 53 | virtual void video_start(); |
| 63 | 54 | UINT32 screen_update_stlforce(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 64 | 55 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ); |
| 56 | required_device<cpu_device> m_maincpu; |
| 57 | required_device<okim6295_device> m_oki; |
| 58 | required_device<eeprom_serial_93cxx_device> m_eeprom; |
| 59 | required_device<gfxdecode_device> m_gfxdecode; |
| 60 | required_device<palette_device> m_palette; |
| 65 | 61 | }; |
branches/kale/src/mame/video/tia.c
| r243832 | r243833 | |
| 430 | 430 | helper[0] = auto_bitmap_ind16_alloc(machine(), cx, TIA_MAX_SCREEN_HEIGHT); |
| 431 | 431 | helper[1] = auto_bitmap_ind16_alloc(machine(), cx, TIA_MAX_SCREEN_HEIGHT); |
| 432 | 432 | helper[2] = auto_bitmap_ind16_alloc(machine(), cx, TIA_MAX_SCREEN_HEIGHT); |
| 433 | | |
| 434 | | register_save_state(); |
| 435 | 433 | } |
| 436 | 434 | |
| 437 | 435 | |
| r243832 | r243833 | |
| 667 | 665 | |
| 668 | 666 | int tia_video_device::current_x() |
| 669 | 667 | { |
| 670 | | return 3 * ((machine().device<cpu_device>("maincpu")->total_cycles() - frame_cycles) % 76) - 68; |
| 668 | return 3 * ((machine().firstcpu->total_cycles() - frame_cycles) % 76) - 68; |
| 671 | 669 | } |
| 672 | 670 | |
| 673 | 671 | |
| 674 | 672 | int tia_video_device::current_y() |
| 675 | 673 | { |
| 676 | | return (machine().device<cpu_device>("maincpu")->total_cycles() - frame_cycles) / 76; |
| 674 | return (machine().firstcpu->total_cycles() - frame_cycles) / 76; |
| 677 | 675 | } |
| 678 | 676 | |
| 679 | 677 | |
| r243832 | r243833 | |
| 1012 | 1010 | |
| 1013 | 1011 | WRITE8_MEMBER( tia_video_device::WSYNC_w ) |
| 1014 | 1012 | { |
| 1015 | | int cycles = machine().device<cpu_device>("maincpu")->total_cycles() - frame_cycles; |
| 1013 | int cycles = machine().firstcpu->total_cycles() - frame_cycles; |
| 1016 | 1014 | |
| 1017 | 1015 | if (cycles % 76) |
| 1018 | 1016 | { |
| r243832 | r243833 | |
| 1053 | 1051 | { |
| 1054 | 1052 | if (data & 0x80) |
| 1055 | 1053 | { |
| 1056 | | paddle_start = machine().device<cpu_device>("maincpu")->total_cycles(); |
| 1054 | paddle_start = machine().firstcpu->total_cycles(); |
| 1057 | 1055 | } |
| 1058 | 1056 | if ( ! ( VBLANK & 0x40 ) ) { |
| 1059 | 1057 | INPT4 = 0x80; |
| r243832 | r243833 | |
| 1806 | 1804 | |
| 1807 | 1805 | READ8_MEMBER( tia_video_device::INPT_r ) |
| 1808 | 1806 | { |
| 1809 | | UINT64 elapsed = machine().device<cpu_device>("maincpu")->total_cycles() - paddle_start; |
| 1807 | UINT64 elapsed = machine().firstcpu->total_cycles() - paddle_start; |
| 1810 | 1808 | UINT16 input = TIA_INPUT_PORT_ALWAYS_ON; |
| 1811 | 1809 | if ( !m_read_input_port_cb.isnull() ) |
| 1812 | 1810 | { |
| r243832 | r243833 | |
| 2179 | 2177 | COLUBK = 0; |
| 2180 | 2178 | COLUPF = 0; |
| 2181 | 2179 | } |
| 2182 | | |
| 2183 | | |
| 2184 | | void tia_video_device::register_save_state() |
| 2185 | | { |
| 2186 | | save_item(NAME(p0gfx.start_pixel)); |
| 2187 | | save_item(NAME(p0gfx.start_drawing)); |
| 2188 | | save_item(NAME(p0gfx.size)); |
| 2189 | | save_item(NAME(p0gfx.skipclip)); |
| 2190 | | save_item(NAME(p1gfx.start_pixel)); |
| 2191 | | save_item(NAME(p1gfx.start_drawing)); |
| 2192 | | save_item(NAME(p1gfx.size)); |
| 2193 | | save_item(NAME(p1gfx.skipclip)); |
| 2194 | | save_item(NAME(frame_cycles)); |
| 2195 | | save_item(NAME(paddle_start)); |
| 2196 | | save_item(NAME(horzP0)); |
| 2197 | | save_item(NAME(horzP1)); |
| 2198 | | save_item(NAME(horzM0)); |
| 2199 | | save_item(NAME(horzM1)); |
| 2200 | | save_item(NAME(horzBL)); |
| 2201 | | save_item(NAME(motclkP0)); |
| 2202 | | save_item(NAME(motclkP1)); |
| 2203 | | save_item(NAME(motclkM0)); |
| 2204 | | save_item(NAME(motclkM1)); |
| 2205 | | save_item(NAME(motclkBL)); |
| 2206 | | save_item(NAME(startP0)); |
| 2207 | | save_item(NAME(startP1)); |
| 2208 | | save_item(NAME(startM0)); |
| 2209 | | save_item(NAME(startM1)); |
| 2210 | | save_item(NAME(skipclipP0)); |
| 2211 | | save_item(NAME(skipclipP1)); |
| 2212 | | save_item(NAME(skipM0delay)); |
| 2213 | | save_item(NAME(skipM1delay)); |
| 2214 | | save_item(NAME(current_bitmap)); |
| 2215 | | save_item(NAME(prev_x)); |
| 2216 | | save_item(NAME(prev_y)); |
| 2217 | | save_item(NAME(VSYNC)); |
| 2218 | | save_item(NAME(VBLANK)); |
| 2219 | | save_item(NAME(COLUP0)); |
| 2220 | | save_item(NAME(COLUP1)); |
| 2221 | | save_item(NAME(COLUBK)); |
| 2222 | | save_item(NAME(COLUPF)); |
| 2223 | | save_item(NAME(CTRLPF)); |
| 2224 | | save_item(NAME(GRP0)); |
| 2225 | | save_item(NAME(GRP1)); |
| 2226 | | save_item(NAME(REFP0)); |
| 2227 | | save_item(NAME(REFP1)); |
| 2228 | | save_item(NAME(HMP0)); |
| 2229 | | save_item(NAME(HMP1)); |
| 2230 | | save_item(NAME(HMM0)); |
| 2231 | | save_item(NAME(HMM1)); |
| 2232 | | save_item(NAME(HMBL)); |
| 2233 | | save_item(NAME(VDELP0)); |
| 2234 | | save_item(NAME(VDELP1)); |
| 2235 | | save_item(NAME(VDELBL)); |
| 2236 | | save_item(NAME(NUSIZ0)); |
| 2237 | | save_item(NAME(NUSIZ1)); |
| 2238 | | save_item(NAME(ENAM0)); |
| 2239 | | save_item(NAME(ENAM1)); |
| 2240 | | save_item(NAME(ENABL)); |
| 2241 | | save_item(NAME(CXM0P)); |
| 2242 | | save_item(NAME(CXM1P)); |
| 2243 | | save_item(NAME(CXP0FB)); |
| 2244 | | save_item(NAME(CXP1FB)); |
| 2245 | | save_item(NAME(CXM0FB)); |
| 2246 | | save_item(NAME(CXM1FB)); |
| 2247 | | save_item(NAME(CXBLPF)); |
| 2248 | | save_item(NAME(CXPPMM)); |
| 2249 | | save_item(NAME(RESMP0)); |
| 2250 | | save_item(NAME(RESMP1)); |
| 2251 | | save_item(NAME(PF0)); |
| 2252 | | save_item(NAME(PF1)); |
| 2253 | | save_item(NAME(PF2)); |
| 2254 | | save_item(NAME(INPT4)); |
| 2255 | | save_item(NAME(INPT5)); |
| 2256 | | save_item(NAME(prevGRP0)); |
| 2257 | | save_item(NAME(prevGRP1)); |
| 2258 | | save_item(NAME(prevENABL)); |
| 2259 | | save_item(NAME(HMOVE_started)); |
| 2260 | | save_item(NAME(HMOVE_started_previous)); |
| 2261 | | save_item(NAME(HMP0_latch)); |
| 2262 | | save_item(NAME(HMP1_latch)); |
| 2263 | | save_item(NAME(HMM0_latch)); |
| 2264 | | save_item(NAME(HMM1_latch)); |
| 2265 | | save_item(NAME(HMBL_latch)); |
| 2266 | | save_item(NAME(REFLECT)); |
| 2267 | | save_item(NAME(NUSIZx_changed)); |
| 2268 | | } |
branches/kale/src/mess/drivers/ngen.c
| r243832 | r243833 | |
| 87 | 87 | m_vram(*this,"vram"), |
| 88 | 88 | m_fontram(*this,"fontram"), |
| 89 | 89 | m_fdc(*this,"fdc"), |
| 90 | | m_fd0(*this,"fdc:0"), |
| 91 | | m_fdc_timer(*this,"fdc_timer"), |
| 92 | | m_hdc_timer(*this,"hdc_timer") |
| 90 | m_fd0(*this,"fdc:0") |
| 93 | 91 | {} |
| 94 | 92 | |
| 95 | 93 | DECLARE_WRITE_LINE_MEMBER(pit_out0_w); |
| r243832 | r243833 | |
| 100 | 98 | DECLARE_WRITE16_MEMBER(cpu_peripheral_cb); |
| 101 | 99 | DECLARE_WRITE16_MEMBER(peripheral_w); |
| 102 | 100 | DECLARE_READ16_MEMBER(peripheral_r); |
| 103 | | DECLARE_WRITE16_MEMBER(xbus_w); |
| 104 | | DECLARE_READ16_MEMBER(xbus_r); |
| 101 | DECLARE_WRITE16_MEMBER(port00_w); |
| 102 | DECLARE_READ16_MEMBER(port00_r); |
| 105 | 103 | DECLARE_WRITE_LINE_MEMBER(dma_hrq_changed); |
| 106 | 104 | DECLARE_WRITE_LINE_MEMBER(dma_eop_changed); |
| 107 | 105 | DECLARE_WRITE_LINE_MEMBER(dack0_w); |
| r243832 | r243833 | |
| 120 | 118 | DECLARE_WRITE8_MEMBER( dma_1_dack_w ){ } |
| 121 | 119 | DECLARE_WRITE8_MEMBER( dma_2_dack_w ){ } |
| 122 | 120 | DECLARE_WRITE8_MEMBER( dma_3_dack_w ){ popmessage("IOW3: data %02x",data); } |
| 123 | | |
| 124 | | DECLARE_WRITE16_MEMBER(hfd_w); |
| 125 | | DECLARE_READ16_MEMBER(fhd_r); |
| 126 | 121 | DECLARE_WRITE_LINE_MEMBER(fdc_irq_w); |
| 127 | 122 | DECLARE_WRITE_LINE_MEMBER(fdc_drq_w); |
| 128 | 123 | DECLARE_WRITE8_MEMBER(fdc_control_w); |
| r243832 | r243833 | |
| 146 | 141 | optional_shared_ptr<UINT16> m_fontram; |
| 147 | 142 | optional_device<wd2797_t> m_fdc; |
| 148 | 143 | optional_device<floppy_connector> m_fd0; |
| 149 | | optional_device<pit8253_device> m_fdc_timer; |
| 150 | | optional_device<pit8253_device> m_hdc_timer; |
| 151 | 144 | |
| 152 | 145 | void set_dma_channel(int channel, int state); |
| 153 | 146 | |
| 154 | | UINT8 m_xbus_current; // currently selected X-Bus module |
| 155 | 147 | UINT16 m_peripheral; |
| 156 | 148 | UINT16 m_upper; |
| 157 | 149 | UINT16 m_middle; |
| r243832 | r243833 | |
| 273 | 265 | if(mem_mask & 0x00ff) |
| 274 | 266 | m_dma_offset[offset-0x80] = data & 0xff; |
| 275 | 267 | break; |
| 276 | | case 0xc0: // X-Bus modules reset |
| 277 | | m_xbus_current = 0; |
| 278 | | break; |
| 279 | 268 | case 0x10c: |
| 280 | 269 | if(mem_mask & 0x00ff) |
| 281 | 270 | m_pic->write(space,0,data & 0xff); |
| r243832 | r243833 | |
| 397 | 386 | |
| 398 | 387 | // X-bus module select |
| 399 | 388 | // The bootstrap ROM creates a table at 0:FC9h, with a count, followed by the module IDs of each |
| 400 | | // expansion module. The base I/O address for the currently selected module is set by writing to |
| 401 | | // this register (bits 0-7 are ignored) |
| 402 | | // TODO: make expansion modules slot devices |
| 403 | | WRITE16_MEMBER(ngen_state::xbus_w) |
| 389 | // expansion module. The base I/O address for each module is 0x100*module number. |
| 390 | // Module 0 is the main processor module, module 1 is the next module attached, and so on. |
| 391 | WRITE16_MEMBER(ngen_state::port00_w) |
| 404 | 392 | { |
| 405 | | UINT16 addr = (data & 0x00ff) << 8; |
| 406 | | address_space& io = m_maincpu->device_t::memory().space(AS_IO); |
| 407 | | switch(m_xbus_current) |
| 408 | | { |
| 409 | | case 0x00: // Floppy/Hard disk module |
| 410 | | io.install_readwrite_handler(addr,addr+0xff,0,0,read16_delegate(FUNC(ngen_state::fhd_r),this),write16_delegate(FUNC(ngen_state::hfd_w),this)); |
| 411 | | break; |
| 412 | | default: |
| 413 | | m_maincpu->set_input_line(INPUT_LINE_NMI,PULSE_LINE); // reached end of the modules |
| 414 | | break; |
| 415 | | } |
| 416 | | if(addr != 0) |
| 417 | | logerror("SYS: X-Bus module %i address set %04x\n",m_xbus_current+1,addr); |
| 418 | | m_xbus_current++; |
| 393 | m_port00 = data; |
| 394 | logerror("SYS: X-Bus module select %04x\n",data); |
| 419 | 395 | } |
| 420 | 396 | |
| 421 | | // returns X-bus module ID and info in the low byte (can indicate if the device is bootable, has a boot ROM (needs to be written to RAM via DMA), or if it supports a non-80186 CPU) |
| 422 | | // bit 6, I think, indicates a bootable device |
| 423 | | // Known module IDs: |
| 424 | | // 0x1070 - Floppy/Hard disk module |
| 425 | | // 0x3141 - QIC Tape module |
| 426 | | READ16_MEMBER(ngen_state::xbus_r) |
| 397 | // returns X-bus module ID (what is the low byte for?) |
| 398 | READ16_MEMBER(ngen_state::port00_r) |
| 427 | 399 | { |
| 428 | | UINT16 ret = 0xffff; |
| 429 | | |
| 430 | | switch(m_xbus_current) |
| 431 | | { |
| 432 | | case 0x00: |
| 433 | | ret = 0x1070; // Floppy/Hard disk module |
| 434 | | break; |
| 435 | | default: |
| 436 | | m_maincpu->set_input_line(INPUT_LINE_NMI,PULSE_LINE); // reached the end of the modules |
| 437 | | ret = 0x0080; |
| 438 | | break; |
| 439 | | } |
| 440 | | return ret; |
| 400 | if(m_port00 > 0) |
| 401 | m_maincpu->set_input_line(INPUT_LINE_NMI,PULSE_LINE); |
| 402 | if(m_port00 == 0) |
| 403 | return 0x1070; // module ID of 0x1070, according to the floppy/hard disk tech manual |
| 404 | else |
| 405 | return 0x0080; // invalid device? |
| 441 | 406 | } |
| 442 | 407 | |
| 443 | | |
| 444 | | // Floppy/Hard disk module |
| 445 | | WRITE16_MEMBER(ngen_state::hfd_w) |
| 446 | | { |
| 447 | | switch(offset) |
| 448 | | { |
| 449 | | case 0x00: |
| 450 | | case 0x01: |
| 451 | | case 0x02: |
| 452 | | case 0x03: |
| 453 | | if(mem_mask & 0x00ff) |
| 454 | | m_fdc->write(space,offset,data & 0xff); |
| 455 | | break; |
| 456 | | case 0x04: |
| 457 | | if(mem_mask & 0x00ff) |
| 458 | | fdc_control_w(space,offset,data & 0xff); |
| 459 | | break; |
| 460 | | case 0x05: |
| 461 | | if(mem_mask & 0x00ff) |
| 462 | | hdc_control_w(space,offset,data & 0xff); |
| 463 | | break; |
| 464 | | case 0x07: |
| 465 | | if(mem_mask & 0x00ff) |
| 466 | | disk_addr_ext(space,offset,data & 0xff); |
| 467 | | break; |
| 468 | | case 0x08: |
| 469 | | case 0x09: |
| 470 | | case 0x0a: |
| 471 | | case 0x0b: |
| 472 | | if(mem_mask & 0x00ff) |
| 473 | | m_fdc_timer->write(space,offset,data & 0xff); |
| 474 | | break; |
| 475 | | case 0x10: |
| 476 | | case 0x11: |
| 477 | | case 0x12: |
| 478 | | case 0x13: |
| 479 | | case 0x14: |
| 480 | | case 0x15: |
| 481 | | case 0x16: |
| 482 | | case 0x17: |
| 483 | | logerror("WD1010 register %i write %02x mask %04x\n",offset-0x10,data & 0xff,mem_mask); |
| 484 | | break; |
| 485 | | case 0x18: |
| 486 | | case 0x19: |
| 487 | | case 0x1a: |
| 488 | | case 0x1b: |
| 489 | | if(mem_mask & 0x00ff) |
| 490 | | m_hdc_timer->write(space,offset,data & 0xff); |
| 491 | | break; |
| 492 | | } |
| 493 | | } |
| 494 | | |
| 495 | | READ16_MEMBER(ngen_state::fhd_r) |
| 496 | | { |
| 497 | | UINT16 ret = 0xffff; |
| 498 | | |
| 499 | | switch(offset) |
| 500 | | { |
| 501 | | case 0x00: |
| 502 | | case 0x01: |
| 503 | | case 0x02: |
| 504 | | case 0x03: |
| 505 | | if(mem_mask & 0x00ff) |
| 506 | | ret = m_fdc->read(space,offset); |
| 507 | | break; |
| 508 | | case 0x08: |
| 509 | | case 0x09: |
| 510 | | case 0x0a: |
| 511 | | case 0x0b: |
| 512 | | if(mem_mask & 0x00ff) |
| 513 | | ret = m_fdc_timer->read(space,offset); |
| 514 | | break; |
| 515 | | case 0x10: |
| 516 | | case 0x11: |
| 517 | | case 0x12: |
| 518 | | case 0x13: |
| 519 | | case 0x14: |
| 520 | | case 0x15: |
| 521 | | case 0x16: |
| 522 | | case 0x17: |
| 523 | | logerror("WD1010 register %i read, mask %04x\n",offset-0x10,mem_mask); |
| 524 | | break; |
| 525 | | case 0x18: |
| 526 | | case 0x19: |
| 527 | | case 0x1a: |
| 528 | | case 0x1b: |
| 529 | | if(mem_mask & 0x00ff) |
| 530 | | ret = m_hdc_timer->read(space,offset); |
| 531 | | break; |
| 532 | | } |
| 533 | | |
| 534 | | return ret; |
| 535 | | } |
| 536 | | |
| 537 | 408 | WRITE_LINE_MEMBER(ngen_state::fdc_irq_w) |
| 538 | 409 | { |
| 539 | 410 | m_pic->ir7_w(state); |
| r243832 | r243833 | |
| 693 | 564 | { |
| 694 | 565 | m_port00 = 0; |
| 695 | 566 | m_control = 0; |
| 696 | | m_xbus_current = 0; |
| 697 | 567 | m_viduart->write_dsr(0); |
| 698 | 568 | m_viduart->write_cts(0); |
| 699 | 569 | m_fd0->get_device()->set_rpm(300); |
| r243832 | r243833 | |
| 708 | 578 | ADDRESS_MAP_END |
| 709 | 579 | |
| 710 | 580 | static ADDRESS_MAP_START( ngen_io, AS_IO, 16, ngen_state ) |
| 711 | | AM_RANGE(0x0000, 0x0001) AM_READWRITE(xbus_r,xbus_w) |
| 581 | AM_RANGE(0x0000, 0x0001) AM_READWRITE(port00_r,port00_w) |
| 712 | 582 | |
| 583 | // TODO: allow for expansion modules to be allocated where asked to |
| 713 | 584 | // Floppy/Hard disk module |
| 714 | | // AM_RANGE(0x0100, 0x0107) AM_DEVREADWRITE8("fdc",wd2797_t,read,write,0x00ff) // a guess for now |
| 715 | | // AM_RANGE(0x0108, 0x0109) AM_WRITE8(fdc_control_w,0x00ff) |
| 716 | | // AM_RANGE(0x010a, 0x010b) AM_WRITE8(hdc_control_w,0x00ff) |
| 717 | | // AM_RANGE(0x010e, 0x010f) AM_WRITE8(disk_addr_ext,0x00ff) // X-Bus extended address register |
| 718 | | // AM_RANGE(0x0110, 0x0117) AM_DEVREADWRITE8("fdc_timer",pit8253_device,read,write,0x00ff) |
| 585 | AM_RANGE(0x0100, 0x0107) AM_DEVREADWRITE8("fdc",wd2797_t,read,write,0x00ff) // a guess for now |
| 586 | AM_RANGE(0x0108, 0x0109) AM_WRITE8(fdc_control_w,0x00ff) |
| 587 | AM_RANGE(0x010a, 0x010b) AM_WRITE8(hdc_control_w,0x00ff) |
| 588 | AM_RANGE(0x010e, 0x010f) AM_WRITE8(disk_addr_ext,0x00ff) // X-Bus extended address register |
| 589 | AM_RANGE(0x0110, 0x0117) AM_DEVREADWRITE8("fdc_timer",pit8253_device,read,write,0x00ff) |
| 719 | 590 | // 0x0120-0x012f - WD1010 Winchester disk controller (unemulated) |
| 720 | | // AM_RANGE(0x0130, 0x0137) AM_DEVREADWRITE8("hdc_timer",pit8253_device,read,write,0x00ff) |
| 591 | AM_RANGE(0x0130, 0x0137) AM_DEVREADWRITE8("hdc_timer",pit8253_device,read,write,0x00ff) |
| 721 | 592 | |
| 722 | 593 | ADDRESS_MAP_END |
| 723 | 594 | |
branches/kale/src/mess/drivers/splitsec.c
| r243832 | r243833 | |
| 1 | | // license:BSD-3-Clause |
| 2 | | // copyright-holders:hap |
| 3 | | /*************************************************************************** |
| 4 | | |
| 5 | | Parker Brothers Split Second |
| 6 | | * TMS1400NLL MP7314-N2 (die labeled MP7314) |
| 7 | | |
| 8 | | |
| 9 | | ***************************************************************************/ |
| 10 | | |
| 11 | | #include "emu.h" |
| 12 | | #include "cpu/tms0980/tms0980.h" |
| 13 | | #include "sound/speaker.h" |
| 14 | | |
| 15 | | #include "splitsec.lh" |
| 16 | | |
| 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) |
| 20 | | |
| 21 | | |
| 22 | | class splitsec_state : public driver_device |
| 23 | | { |
| 24 | | public: |
| 25 | | splitsec_state(const machine_config &mconfig, device_type type, const char *tag) |
| 26 | | : driver_device(mconfig, type, tag), |
| 27 | | m_maincpu(*this, "maincpu"), |
| 28 | | m_button_matrix(*this, "IN"), |
| 29 | | m_speaker(*this, "speaker") |
| 30 | | { } |
| 31 | | |
| 32 | | required_device<cpu_device> m_maincpu; |
| 33 | | required_ioport_array<2> m_button_matrix; |
| 34 | | required_device<speaker_sound_device> m_speaker; |
| 35 | | |
| 36 | | UINT16 m_r; |
| 37 | | UINT16 m_o; |
| 38 | | |
| 39 | | UINT16 m_leds_state[0x10]; |
| 40 | | UINT16 m_leds_cache[0x10]; |
| 41 | | UINT8 m_leds_decay[0x100]; |
| 42 | | |
| 43 | | DECLARE_READ8_MEMBER(read_k); |
| 44 | | DECLARE_WRITE16_MEMBER(write_o); |
| 45 | | DECLARE_WRITE16_MEMBER(write_r); |
| 46 | | |
| 47 | | TIMER_DEVICE_CALLBACK_MEMBER(leds_decay_tick); |
| 48 | | void leds_update(); |
| 49 | | |
| 50 | | virtual void machine_start(); |
| 51 | | }; |
| 52 | | |
| 53 | | |
| 54 | | |
| 55 | | /*************************************************************************** |
| 56 | | |
| 57 | | LEDs |
| 58 | | |
| 59 | | ***************************************************************************/ |
| 60 | | |
| 61 | | // The device strobes the outputs very fast, it is unnoticeable to the user. |
| 62 | | // To prevent flickering here, we need to simulate a decay. |
| 63 | | |
| 64 | | // decay time, in steps of 10ms |
| 65 | | #define LEDS_DECAY_TIME 4 |
| 66 | | |
| 67 | | void splitsec_state::leds_update() |
| 68 | | { |
| 69 | | UINT16 active_state[0x10]; |
| 70 | | |
| 71 | | for (int i = 0; i < 0x10; i++) |
| 72 | | { |
| 73 | | // update current state |
| 74 | | if (m_r >> i & 1) |
| 75 | | m_leds_state[i] = m_o; |
| 76 | | |
| 77 | | active_state[i] = 0; |
| 78 | | |
| 79 | | for (int j = 0; j < 0x10; j++) |
| 80 | | { |
| 81 | | int di = j << 4 | i; |
| 82 | | |
| 83 | | // turn on powered leds |
| 84 | | if (m_leds_state[i] >> j & 1) |
| 85 | | m_leds_decay[di] = LEDS_DECAY_TIME; |
| 86 | | |
| 87 | | // determine active state |
| 88 | | int ds = (m_leds_decay[di] != 0) ? 1 : 0; |
| 89 | | active_state[i] |= (ds << j); |
| 90 | | } |
| 91 | | } |
| 92 | | |
| 93 | | // on difference, send to output |
| 94 | | for (int i = 0; i < 0x10; i++) |
| 95 | | if (m_leds_cache[i] != active_state[i]) |
| 96 | | { |
| 97 | | for (int j = 0; j < 8; j++) |
| 98 | | output_set_lamp_value(i*10 + j, active_state[i] >> j & 1); |
| 99 | | } |
| 100 | | |
| 101 | | memcpy(m_leds_cache, active_state, sizeof(m_leds_cache)); |
| 102 | | } |
| 103 | | |
| 104 | | TIMER_DEVICE_CALLBACK_MEMBER(splitsec_state::leds_decay_tick) |
| 105 | | { |
| 106 | | // slowly turn off unpowered leds |
| 107 | | for (int i = 0; i < 0x100; i++) |
| 108 | | if (!(m_leds_state[i & 0xf] >> (i>>4) & 1) && m_leds_decay[i]) |
| 109 | | m_leds_decay[i]--; |
| 110 | | |
| 111 | | leds_update(); |
| 112 | | } |
| 113 | | |
| 114 | | |
| 115 | | |
| 116 | | /*************************************************************************** |
| 117 | | |
| 118 | | I/O |
| 119 | | |
| 120 | | ***************************************************************************/ |
| 121 | | |
| 122 | | READ8_MEMBER(splitsec_state::read_k) |
| 123 | | { |
| 124 | | UINT8 k = 0; |
| 125 | | |
| 126 | | // read selected button rows |
| 127 | | for (int i = 0; i < 2; i++) |
| 128 | | if (m_r >> (i+9) & 1) |
| 129 | | k |= m_button_matrix[i]->read(); |
| 130 | | |
| 131 | | return k; |
| 132 | | } |
| 133 | | |
| 134 | | WRITE16_MEMBER(splitsec_state::write_r) |
| 135 | | { |
| 136 | | // R8: speaker out |
| 137 | | m_speaker->level_w(data >> 8 & 1); |
| 138 | | |
| 139 | | // R9,R10: input mux |
| 140 | | // R0-R7: led columns |
| 141 | | m_r = data; |
| 142 | | leds_update(); |
| 143 | | } |
| 144 | | |
| 145 | | WRITE16_MEMBER(splitsec_state::write_o) |
| 146 | | { |
| 147 | | // O0-O6: led rows |
| 148 | | // O7: N/C |
| 149 | | m_o = data; |
| 150 | | leds_update(); |
| 151 | | } |
| 152 | | |
| 153 | | |
| 154 | | |
| 155 | | /*************************************************************************** |
| 156 | | |
| 157 | | Inputs |
| 158 | | |
| 159 | | ***************************************************************************/ |
| 160 | | |
| 161 | | static INPUT_PORTS_START( splitsec ) |
| 162 | | PORT_START("IN.0") // R9 |
| 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 ) |
| 166 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 167 | | |
| 168 | | PORT_START("IN.1") // R10 |
| 169 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) |
| 170 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Select") |
| 171 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Start") |
| 172 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 173 | | INPUT_PORTS_END |
| 174 | | |
| 175 | | |
| 176 | | |
| 177 | | /*************************************************************************** |
| 178 | | |
| 179 | | Machine Config |
| 180 | | |
| 181 | | ***************************************************************************/ |
| 182 | | |
| 183 | | void splitsec_state::machine_start() |
| 184 | | { |
| 185 | | // zerofill |
| 186 | | memset(m_leds_state, 0, sizeof(m_leds_state)); |
| 187 | | memset(m_leds_cache, 0, sizeof(m_leds_cache)); |
| 188 | | memset(m_leds_decay, 0, sizeof(m_leds_decay)); |
| 189 | | |
| 190 | | m_r = 0; |
| 191 | | m_o = 0; |
| 192 | | |
| 193 | | // register for savestates |
| 194 | | save_item(NAME(m_leds_state)); |
| 195 | | save_item(NAME(m_leds_cache)); |
| 196 | | save_item(NAME(m_leds_decay)); |
| 197 | | |
| 198 | | save_item(NAME(m_r)); |
| 199 | | save_item(NAME(m_o)); |
| 200 | | } |
| 201 | | |
| 202 | | |
| 203 | | static MACHINE_CONFIG_START( splitsec, splitsec_state ) |
| 204 | | |
| 205 | | /* basic machine hardware */ |
| 206 | | MCFG_CPU_ADD("maincpu", TMS1400, MASTER_CLOCK) |
| 207 | | MCFG_TMS1XXX_READ_K_CB(READ8(splitsec_state, read_k)) |
| 208 | | MCFG_TMS1XXX_WRITE_O_CB(WRITE16(splitsec_state, write_o)) |
| 209 | | MCFG_TMS1XXX_WRITE_R_CB(WRITE16(splitsec_state, write_r)) |
| 210 | | |
| 211 | | MCFG_TIMER_DRIVER_ADD_PERIODIC("leds_decay", splitsec_state, leds_decay_tick, attotime::from_msec(10)) |
| 212 | | |
| 213 | | MCFG_DEFAULT_LAYOUT(layout_splitsec) |
| 214 | | |
| 215 | | /* no video! */ |
| 216 | | |
| 217 | | /* sound hardware */ |
| 218 | | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 219 | | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 220 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 221 | | MACHINE_CONFIG_END |
| 222 | | |
| 223 | | |
| 224 | | |
| 225 | | /*************************************************************************** |
| 226 | | |
| 227 | | Game driver(s) |
| 228 | | |
| 229 | | ***************************************************************************/ |
| 230 | | |
| 231 | | ROM_START( splitsec ) |
| 232 | | ROM_REGION( 0x1000, "maincpu", 0 ) |
| 233 | | ROM_LOAD( "tms1400nll_mp7314", 0x0000, 0x1000, CRC(0cccdf59) SHA1(06a533134a433aaf856b80f0ca239d0498b98d5f) ) |
| 234 | | |
| 235 | | ROM_REGION( 867, "maincpu:mpla", 0 ) |
| 236 | | ROM_LOAD( "tms1100_default_mpla.pla", 0, 867, CRC(62445fc9) SHA1(d6297f2a4bc7a870b76cc498d19dbb0ce7d69fec) ) |
| 237 | | ROM_REGION( 557, "maincpu:opla", 0 ) |
| 238 | | ROM_LOAD( "tms1400_splitsec_opla.pla", 0, 557, CRC(7539283b) SHA1(f791fa98259fc10c393ff1961d4c93040f1a2932) ) |
| 239 | | ROM_END |
| 240 | | |
| 241 | | |
| 242 | | CONS( 1980, splitsec, 0, 0, splitsec, splitsec, driver_device, 0, "Parker Brothers", "Split Second", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) |
branches/kale/src/mess/layout/splitsec.lay
| r243832 | r243833 | |
| 1 | | <?xml version="1.0"?> |
| 2 | | <mamelayout version="2"> |
| 3 | | |
| 4 | | <!-- define elements --> |
| 5 | | |
| 6 | | <element name="static_black"><rect><color red="0.0" green="0.0" blue="0.0" /></rect></element> |
| 7 | | |
| 8 | | <element name="lamp_disk" defstate="0"> |
| 9 | | <disk state="1"><color red="1.0" green="0.24" blue="0.26" /></disk> |
| 10 | | <disk state="0"><color red="0.15" green="0.043" blue="0.047" /></disk> |
| 11 | | </element> |
| 12 | | <element name="lamp_rect" defstate="0"> |
| 13 | | <rect state="1"><color red="1.0" green="0.24" blue="0.26" /></rect> |
| 14 | | <rect state="0"><color red="0.15" green="0.043" blue="0.047" /></rect> |
| 15 | | </element> |
| 16 | | |
| 17 | | |
| 18 | | <!-- build screen --> |
| 19 | | |
| 20 | | <view name="Internal Layout"> |
| 21 | | <bounds left="0" right="18" top="0" bottom="28" /> |
| 22 | | <bezel element="static_black"> |
| 23 | | <bounds left="0" right="18" top="0" bottom="28" /> |
| 24 | | </bezel> |
| 25 | | |
| 26 | | <!-- maze of lamps --> |
| 27 | | |
| 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 | | |
| 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 | | <bezel name="lamp3" element="lamp_disk"><bounds x="8" y="3" width="2" height="2" /></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 | | |
| 40 | | <bezel name="lamp15" element="lamp_rect"><bounds x="2" y="6" width="4" height="1" /></bezel> |
| 41 | | <bezel name="lamp13" element="lamp_rect"><bounds x="7" 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 | | |
| 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 | | <bezel name="lamp23" element="lamp_disk"><bounds x="8" y="8" width="2" height="2" /></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 | | |
| 52 | | <bezel name="lamp35" element="lamp_rect"><bounds x="2" y="11" width="4" height="1" /></bezel> |
| 53 | | <bezel name="lamp33" element="lamp_rect"><bounds x="7" 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 | | |
| 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 | | <bezel name="lamp43" element="lamp_disk"><bounds x="8" y="13" width="2" height="2" /></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 | | |
| 64 | | <bezel name="lamp55" element="lamp_rect"><bounds x="2" y="16" width="4" height="1" /></bezel> |
| 65 | | <bezel name="lamp53" element="lamp_rect"><bounds x="7" 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 | | |
| 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 | | <bezel name="lamp63" element="lamp_disk"><bounds x="8" y="18" width="2" height="2" /></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 | | |
| 76 | | <bezel name="lamp75" element="lamp_rect"><bounds x="2" y="21" width="4" height="1" /></bezel> |
| 77 | | <bezel name="lamp73" element="lamp_rect"><bounds x="7" 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 | | |
| 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 | | |
| 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 | | |
| 92 | | </view> |
| 93 | | </mamelayout> |
branches/kale/src/osd/sdl/sdlmain.c
| r243832 | r243833 | |
| 717 | 717 | // font with the given name |
| 718 | 718 | //------------------------------------------------- |
| 719 | 719 | |
| 720 | | class osd_font |
| 720 | osd_font sdl_osd_interface::font_open(const char *_name, int &height) |
| 721 | 721 | { |
| 722 | | public: |
| 723 | | CTFontRef m_font; |
| 724 | | }; |
| 725 | | |
| 726 | | osd_font *sdl_osd_interface::font_open(const char *_name, int &height) |
| 727 | | { |
| 728 | 722 | CFStringRef font_name = NULL; |
| 729 | 723 | CTFontRef ct_font = NULL; |
| 730 | 724 | CTFontDescriptorRef font_descriptor; |
| r243832 | r243833 | |
| 776 | 770 | line_height += CTFontGetLeading(ct_font); |
| 777 | 771 | height = ceilf(line_height * EXTRA_HEIGHT); |
| 778 | 772 | |
| 779 | | osd_font *ret = global_alloc(osd_font); |
| 780 | | ret->m_font = ct_font; |
| 781 | | return ret; |
| 773 | return (osd_font)ct_font; |
| 782 | 774 | } |
| 783 | 775 | |
| 784 | 776 | //------------------------------------------------- |
| r243832 | r243833 | |
| 786 | 778 | // a given OSD font |
| 787 | 779 | //------------------------------------------------- |
| 788 | 780 | |
| 789 | | void sdl_osd_interface::font_close(osd_font *font) |
| 781 | void sdl_osd_interface::font_close(osd_font font) |
| 790 | 782 | { |
| 791 | | CTFontRef ct_font = font->m_font; |
| 783 | CTFontRef ct_font = (CTFontRef)font; |
| 792 | 784 | |
| 793 | 785 | if( ct_font != NULL ) |
| 794 | 786 | { |
| 795 | 787 | CFRelease( ct_font ); |
| 796 | 788 | } |
| 797 | | global_free(font); |
| 798 | 789 | } |
| 799 | 790 | |
| 800 | 791 | //------------------------------------------------- |
| r243832 | r243833 | |
| 805 | 796 | // pixel of a black & white font |
| 806 | 797 | //------------------------------------------------- |
| 807 | 798 | |
| 808 | | bool sdl_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 799 | bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 809 | 800 | { |
| 810 | 801 | UniChar uni_char; |
| 811 | 802 | CGGlyph glyph; |
| 812 | | CTFontRef ct_font = font->m_font; |
| 803 | CTFontRef ct_font = (CTFontRef)font; |
| 813 | 804 | const CFIndex count = 1; |
| 814 | 805 | CGRect bounding_rect, success_rect; |
| 815 | 806 | CGContextRef context_ref; |
| r243832 | r243833 | |
| 1018 | 1009 | // font with the given name |
| 1019 | 1010 | //------------------------------------------------- |
| 1020 | 1011 | |
| 1021 | | class osd_font |
| 1012 | osd_font sdl_osd_interface::font_open(const char *_name, int &height) |
| 1022 | 1013 | { |
| 1023 | | public: |
| 1024 | | TTF_Font *m_font; |
| 1025 | | }; |
| 1026 | | |
| 1027 | | osd_font *sdl_osd_interface::font_open(const char *_name, int &height) |
| 1028 | | { |
| 1029 | 1014 | TTF_Font *font = (TTF_Font *)NULL; |
| 1030 | 1015 | bool bakedstyles = false; |
| 1031 | 1016 | int style = 0; |
| r243832 | r243833 | |
| 1096 | 1081 | |
| 1097 | 1082 | height = TTF_FontLineSkip(font); |
| 1098 | 1083 | |
| 1099 | | osd_font *ret = global_alloc(osd_font); |
| 1100 | | ret->m_font = font; |
| 1101 | | return ret; |
| 1084 | return (osd_font)font; |
| 1102 | 1085 | } |
| 1103 | 1086 | |
| 1104 | 1087 | //------------------------------------------------- |
| r243832 | r243833 | |
| 1106 | 1089 | // a given OSD font |
| 1107 | 1090 | //------------------------------------------------- |
| 1108 | 1091 | |
| 1109 | | void sdl_osd_interface::font_close(osd_font *font) |
| 1092 | void sdl_osd_interface::font_close(osd_font font) |
| 1110 | 1093 | { |
| 1111 | | TTF_CloseFont(font->m_font); |
| 1112 | | global_free(font); |
| 1094 | TTF_Font *ttffont; |
| 1095 | |
| 1096 | ttffont = (TTF_Font *)font; |
| 1097 | |
| 1098 | TTF_CloseFont(ttffont); |
| 1113 | 1099 | } |
| 1114 | 1100 | |
| 1115 | 1101 | //------------------------------------------------- |
| r243832 | r243833 | |
| 1120 | 1106 | // pixel of a black & white font |
| 1121 | 1107 | //------------------------------------------------- |
| 1122 | 1108 | |
| 1123 | | bool sdl_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 1109 | bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) |
| 1124 | 1110 | { |
| 1125 | 1111 | TTF_Font *ttffont; |
| 1126 | 1112 | SDL_Surface *drawsurf; |
| 1127 | 1113 | SDL_Color fcol = { 0xff, 0xff, 0xff }; |
| 1128 | 1114 | UINT16 ustr[16]; |
| 1129 | 1115 | |
| 1130 | | ttffont = font->m_font; |
| 1116 | ttffont = (TTF_Font *)font; |
| 1131 | 1117 | |
| 1132 | 1118 | memset(ustr,0,sizeof(ustr)); |
| 1133 | 1119 | ustr[0] = (UINT16)chnum; |