src/emu/sound/disc_mth.c
| r9518 | r9519 | |
| 366 | 366 | context->last_v = 0; |
| 367 | 367 | |
| 368 | 368 | /* Calculate the Millman current of the bias circuit */ |
| 369 | | if (info->rBias) |
| 369 | if (info->rBias > 0) |
| 370 | 370 | i_bias = info->vBias / info->rBias; |
| 371 | 371 | else |
| 372 | 372 | i_bias = 0; |
| r9518 | r9519 | |
| 393 | 393 | */ |
| 394 | 394 | for(bit = 0; bit < ladderLength; bit++) |
| 395 | 395 | { |
| 396 | | if (info->r[bit] != 0) |
| 396 | if (info->r[bit] > 0) |
| 397 | 397 | r_total += 1.0 / info->r[bit]; |
| 398 | 398 | } |
| 399 | | if (info->rBias) r_total += 1.0 / info->rBias; |
| 400 | | if (info->rGnd) r_total += 1.0 / info->rGnd; |
| 399 | if (info->rBias > 0) r_total += 1.0 / info->rBias; |
| 400 | if (info->rGnd > 0) r_total += 1.0 / info->rGnd; |
| 401 | 401 | r_total = 1.0 / r_total; |
| 402 | 402 | |
| 403 | 403 | node->output[0] = 0; |
| r9518 | r9519 | |
| 420 | 420 | /* Add up currents of ON circuits per Millman. */ |
| 421 | 421 | |
| 422 | 422 | /* ignore if no resistor present */ |
| 423 | | if (EXPECTED(info->r[bit] != 0)) |
| 423 | if (EXPECTED(info->r[bit] > 0)) |
| 424 | 424 | { |
| 425 | 425 | double i_bit; |
| 426 | 426 | int bit_val = (i >> bit) & 0x01; |
src/emu/sound/discrete.h
| r9518 | r9519 | |
| 3340 | 3340 | * |
| 3341 | 3341 | * Declaration syntax |
| 3342 | 3342 | * |
| 3343 | | * DISCRETE_74LS624(name of node,(NODE,ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,OUTTYPE) |
| 3343 | * DISCRETE_74LS624(name of node,(NODE,ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,R_RNG_IN,OUTTYPE) |
| 3344 | 3344 | * enable node or static value, |
| 3345 | 3345 | * vMod node or static value, |
| 3346 | 3346 | * vRng static value, |
| r9518 | r9519 | |
| 3354 | 3354 | * DISC_LS624_OUT_SQUARE - 4.4V square wave |
| 3355 | 3355 | * DISC_LS624_OUT_ENERGY - 4.4V anti-aliased square wave |
| 3356 | 3356 | * DISC_LS624_OUT_LOGIC - Logic ( 0 or 1) |
| 3357 | | * DISC_LS624_OUT_LOGIC_X - Logic ( 0 or 1) with xime |
| 3357 | * DISC_LS624_OUT_LOGIC_X - Logic ( 0 or 1) with x_time |
| 3358 | 3358 | * DISC_LS624_OUT_COUNT_F - Number of Falling edges |
| 3359 | | * DISC_LS624_OUT_COUNT_F_X - Number of Falling edges with xime |
| 3359 | * DISC_LS624_OUT_COUNT_F_X - Number of Falling edges with x_time |
| 3360 | 3360 | * DISC_LS624_OUT_COUNT_R - Number of Rising edges |
| 3361 | | * DISC_LS624_OUT_COUNT_R_X - Number of Rising edges with xime |
| 3361 | * DISC_LS624_OUT_COUNT_R_X - Number of Rising edges with x_time |
| 3362 | 3362 | * |
| 3363 | 3363 | * |
| 3364 | 3364 | * EXAMPLES: see Donkey Kong Jr.; Mario Bros. |
src/emu/sound/disc_wav.c
| r9518 | r9519 | |
| 33 | 33 | int clock_type; |
| 34 | 34 | int out_type; |
| 35 | 35 | int is_7492; |
| 36 | int last_clock; |
| 37 | UINT32 last_count; |
| 36 | 38 | UINT32 last; /* Last clock state */ |
| 37 | 39 | UINT32 min; |
| 38 | 40 | UINT32 max; |
| r9518 | r9519 | |
| 196 | 198 | |
| 197 | 199 | double cycles; |
| 198 | 200 | double ds_clock; |
| 199 | | int clock = 0, last_count, inc = 0; |
| 201 | int clock = 0, inc = 0; |
| 202 | UINT32 last_count = context->last_count; /* it is different then output in 7492 */ |
| 200 | 203 | double x_time = 0; |
| 201 | | UINT32 count = node->output[0]; |
| 204 | UINT32 count = last_count; |
| 202 | 205 | |
| 203 | 206 | ds_clock = DSS_COUNTER__CLOCK; |
| 204 | 207 | if (UNEXPECTED(context->clock_type == DISC_CLK_IS_FREQ)) |
| r9518 | r9519 | |
| 220 | 223 | /* If reset enabled then set output to the reset value. No x_time in reset. */ |
| 221 | 224 | if (UNEXPECTED(DSS_COUNTER__RESET)) |
| 222 | 225 | { |
| 226 | context->last_count = (int)DSS_COUNTER__INIT; |
| 223 | 227 | node->output[0] = (int)DSS_COUNTER__INIT; |
| 224 | 228 | return; |
| 225 | 229 | } |
| r9518 | r9519 | |
| 230 | 234 | */ |
| 231 | 235 | if (EXPECTED(DSS_COUNTER__ENABLE)) |
| 232 | 236 | { |
| 233 | | last_count = count; |
| 234 | | |
| 235 | 237 | switch (context->clock_type) |
| 236 | 238 | { |
| 237 | 239 | case DISC_CLK_ON_F_EDGE: |
| 238 | 240 | case DISC_CLK_ON_R_EDGE: |
| 239 | 241 | /* See if the clock has toggled to the proper edge */ |
| 240 | 242 | clock = (clock != 0); |
| 241 | | if (context->last != clock) |
| 243 | if (context->last_clock != clock) |
| 242 | 244 | { |
| 243 | | context->last = clock; |
| 245 | context->last_clock = clock; |
| 244 | 246 | if (context->clock_type == clock) |
| 245 | 247 | { |
| 246 | 248 | /* Toggled */ |
| r9518 | r9519 | |
| 273 | 275 | } |
| 274 | 276 | } |
| 275 | 277 | |
| 278 | context->last_count = count; |
| 276 | 279 | node->output[0] = context->is_7492 ? disc_7492_count[count] : count; |
| 277 | 280 | |
| 278 | 281 | if (UNEXPECTED(count != last_count)) |
| r9518 | r9519 | |
| 300 | 303 | { |
| 301 | 304 | DISCRETE_DECLARE_CONTEXT(dss_counter) |
| 302 | 305 | |
| 303 | | if (DSS_COUNTER__MAX < DSS_COUNTER__MIN) |
| 304 | | fatalerror("MAX < MIN in NODE_%02d", NODE_INDEX(node->block->node)); |
| 305 | | |
| 306 | 306 | if ((int)DSS_COUNTER__CLOCK_TYPE & DISC_COUNTER_IS_7492) |
| 307 | 307 | { |
| 308 | 308 | context->is_7492 = 1; |
| r9518 | r9519 | |
| 319 | 319 | context->min = DSS_COUNTER__MIN; |
| 320 | 320 | context->diff = context->max - context->min + 1; |
| 321 | 321 | } |
| 322 | |
| 323 | |
| 324 | if (!context->is_7492 && (DSS_COUNTER__MAX < DSS_COUNTER__MIN)) |
| 325 | fatalerror("MAX < MIN in NODE_%02d", NODE_INDEX(node->block->node)); |
| 326 | |
| 322 | 327 | context->out_type = context->clock_type & DISC_OUT_MASK; |
| 323 | 328 | context->clock_type &= DISC_CLK_MASK; |
| 324 | 329 | |
| 325 | | context->t_left = 0; |
| 326 | | context->last = 0; |
| 327 | | node->output[0] = DSS_COUNTER__INIT; /* count starts at reset value */ |
| 330 | context->t_left = 0; |
| 331 | context->last_count = 0; |
| 332 | context->last_clock = 0; |
| 333 | node->output[0] = DSS_COUNTER__INIT; /* count starts at reset value */ |
| 328 | 334 | } |
| 329 | 335 | |
| 330 | 336 | |