static STREAM_UPDATE( hc55516_update ) { hc55516_state *chip = (hc55516_state *)param; stream_sample_t *buffer = outputs[0]; int i; INT32 sample, slope; /* zero-length? bail */ if (samples == 0) return; if (!is_external_osciallator(chip)) { /* track how many samples we've updated without a clock */ chip->update_count += samples; if (chip->update_count > SAMPLE_RATE / 32) { chip->update_count = SAMPLE_RATE; chip->next_sample = 0; } } /* compute the interpolation slope */ sample = chip->curr_sample; slope = ((INT32)chip->next_sample - sample) / samples; chip->curr_sample = chip->next_sample; if (is_external_osciallator(chip)) { /* external oscillator */ for (i = 0; i < samples; i++, sample += slope) { UINT8 clock_state; *buffer++ = sample; chip->update_count++; clock_state = current_clock_state(chip); /* pull in next digit on the appropriate edge of the clock */ if (is_active_clock_transition(chip, clock_state)) { chip->digit = chip->new_digit; process_digit(chip); } chip->last_clock_state = clock_state; } } /* software driven clock */ else for (i = 0; i < samples; i++, sample += slope) *buffer++ = sample; }
int main(void){ int curr = 0; char c = 1; clear_digits_array(); printf("Enter a number: "); while (curr < MAX_DIGITS && c != '\n') { if (isdigit(c = getchar())) { process_digit(c - '0', curr++); } } print_digits_array(); }
int main (void){ int i; char ch; clear_digits_away(); printf ("Enter a number: "); for (i = 0; i < MAX_DIGITS; i++){ ch = getchar(); if (ch >='0' && ch <= '9'){ process_digit(ch - '0', i); } } print_digits_array(); printf("\n"); return 0; }
void hc55516_clock_w(device_t *device, int state) { hc55516_state *chip = get_safe_token(device); UINT8 clock_state = state ? TRUE : FALSE; /* only makes sense for setups with a software driven clock */ assert(!is_external_osciallator(chip)); /* speech clock changing? */ if (is_active_clock_transition(chip, clock_state)) { /* update the output buffer before changing the registers */ chip->channel->update(); /* clear the update count */ chip->update_count = 0; process_digit(chip); } /* update the clock */ chip->last_clock_state = clock_state; }