void check_prefs_changed_audio (void) { if (sound_available && sound_prefs_changed ()) { close_sound (); produce_sound = changed_produce_sound; if (produce_sound) { if (init_audio ()) { last_cycles = get_cycles () - 1; next_sample_evtime = scaled_sample_evtime; } else if (! sound_available) { write_log ("Sound is not supported.\n"); } else { write_log ("Sorry, can't initialize sound.\n"); produce_sound = 0; /* So we don't do this every frame */ produce_sound = 0; } } } if (!produce_sound) { eventtab[ev_audio].active = 0; events_schedule (); } }
static void CIA_calctimers (void) { long ciaatimea = -1, ciaatimeb = -1, ciabtimea = -1, ciabtimeb = -1; eventtab[ev_cia].oldcycles = get_cycles (); if ((ciaacra & 0x21) == 0x01) { ciaatimea = (DIV10 - div10) + DIV10 * ciaata; } if ((ciaacrb & 0x61) == 0x01) { ciaatimeb = (DIV10 - div10) + DIV10 * ciaatb; } if ((ciabcra & 0x21) == 0x01) { ciabtimea = (DIV10 - div10) + DIV10 * ciabta; } if ((ciabcrb & 0x61) == 0x01) { ciabtimeb = (DIV10 - div10) + DIV10 * ciabtb; } eventtab[ev_cia].active = (ciaatimea != -1 || ciaatimeb != -1 || ciabtimea != -1 || ciabtimeb != -1); if (eventtab[ev_cia].active) { unsigned long int ciatime = ~0L; if (ciaatimea != -1) ciatime = ciaatimea; if (ciaatimeb != -1 && ciaatimeb < ciatime) ciatime = ciaatimeb; if (ciabtimea != -1 && ciabtimea < ciatime) ciatime = ciabtimea; if (ciabtimeb != -1 && ciabtimeb < ciatime) ciatime = ciabtimeb; eventtab[ev_cia].evtime = ciatime + get_cycles (); } events_schedule(); }
static void CIA_calctimers (void) { long int ciaatimea = -1, ciaatimeb = -1, ciabtimea = -1, ciabtimeb = -1; eventtab[ev_cia].oldcycles = get_cycles (); if ((ciaacra & 0x21) == 0x01) { ciaatimea = (DIV10 - div10) + DIV10 * ciaata; } if ((ciaacrb & 0x61) == 0x41) { /* Timer B will not get any pulses if Timer A is off. */ if (ciaatimea >= 0) { /* If Timer A is in one-shot mode, and Timer B needs more than * one pulse, it will not underflow. */ if (ciaatb == 0 || (ciaacra & 0x8) == 0) { /* Otherwise, we can determine the time of the underflow. */ /* This may overflow, however. So just ignore this timer and use the fact that we'll call CIA_handler for the A timer. */ #if 0 ciaatimeb = ciaatimea + ciaala * DIV10 * ciaatb; #endif } } } if ((ciaacrb & 0x61) == 0x01) { ciaatimeb = (DIV10 - div10) + DIV10 * ciaatb; } if ((ciabcra & 0x21) == 0x01) { ciabtimea = (DIV10 - div10) + DIV10 * ciabta; } if ((ciabcrb & 0x61) == 0x41) { /* Timer B will not get any pulses if Timer A is off. */ if (ciabtimea >= 0) { /* If Timer A is in one-shot mode, and Timer B needs more than * one pulse, it will not underflow. */ if (ciabtb == 0 || (ciabcra & 0x8) == 0) { /* Otherwise, we can determine the time of the underflow. */ #if 0 ciabtimeb = ciabtimea + ciabla * DIV10 * ciabtb; #endif } } } if ((ciabcrb & 0x61) == 0x01) { ciabtimeb = (DIV10 - div10) + DIV10 * ciabtb; } eventtab[ev_cia].active = (ciaatimea != -1 || ciaatimeb != -1 || ciabtimea != -1 || ciabtimeb != -1); if (eventtab[ev_cia].active) { unsigned long int ciatime = ~0L; if (ciaatimea != -1) ciatime = ciaatimea; if (ciaatimeb != -1 && ciaatimeb < ciatime) ciatime = ciaatimeb; if (ciabtimea != -1 && ciabtimea < ciatime) ciatime = ciabtimea; if (ciabtimeb != -1 && ciabtimeb < ciatime) ciatime = ciabtimeb; eventtab[ev_cia].evtime = ciatime + get_cycles (); } events_schedule(); }
static void CIA_calctimers(void) { int ciaatimea = -1, ciaatimeb = -1, ciabtimea = -1, ciabtimeb = -1; eventtab[ev_cia].oldcycles = cycles; if ((ciaacra & 0x21) == 0x01) { ciaatimea = (DIV10-div10) + DIV10*ciaata; } if ((ciaacrb & 0x61) == 0x41) { /* Timer B will not get any pulses if Timer A is off. */ if (ciaatimea >= 0) { /* If Timer A is in one-shot mode, and Timer B needs more than * one pulse, it will not underflow. */ if (ciaatb == 0 || (ciaacra & 0x8) == 0) { /* Otherwise, we can determine the time of the underflow. */ ciaatimeb = ciaatimea + ciaala * DIV10 * ciaatb; } } } if ((ciaacrb & 0x61) == 0x01) { ciaatimeb = (DIV10-div10) + DIV10*ciaatb; } if ((ciabcra & 0x21) == 0x01) { ciabtimea = (DIV10-div10) + DIV10*ciabta; } if ((ciabcrb & 0x61) == 0x41) { /* Timer B will not get any pulses if Timer A is off. */ if (ciabtimea >= 0) { /* If Timer A is in one-shot mode, and Timer B needs more than * one pulse, it will not underflow. */ if (ciabtb == 0 || (ciabcra & 0x8) == 0) { /* Otherwise, we can determine the time of the underflow. */ ciabtimeb = ciabtimea + ciabla * DIV10 * ciabtb; } } } if ((ciabcrb & 0x61) == 0x01) { ciabtimeb = (DIV10-div10) + DIV10*ciabtb; } eventtab[ev_cia].active = (ciaatimea != -1 || ciaatimeb != -1 || ciabtimea != -1 || ciabtimeb != -1); if (eventtab[ev_cia].active) { unsigned long int ciatime = ~0L; if (ciaatimea != -1) ciatime = ciaatimea; if (ciaatimeb != -1 && ((unsigned long int) ciaatimeb) < ciatime) ciatime = ciaatimeb; if (ciabtimea != -1 && ((unsigned long int) ciabtimea) < ciatime) ciatime = ciabtimea; if (ciabtimeb != -1 && ((unsigned long int) ciabtimeb) < ciatime) ciatime = ciabtimeb; eventtab[ev_cia].evtime = ciatime + cycles; } events_schedule(); }
void do_cycles_slow (unsigned long cycles_to_add) { if ((pissoff -= cycles_to_add) >= 0) return; cycles_to_add = -pissoff; pissoff = 0; while ((nextevent - currcycle) <= cycles_to_add) { int i; /* Keep only CPU emulation running while waiting for sync point. */ if (is_syncline) { if (!vblank_found_chipset) { if (is_syncline > 0) { int rpt = read_processor_time (); int v = rpt - vsyncmintime; int v2 = rpt - is_syncline_end; if (v > vsynctimebase || v < -vsynctimebase) { v = 0; } if (v < 0 && v2 < 0) { pissoff = pissoff_value; return; } } else if (is_syncline < 0) { int rpt = read_processor_time (); int v = rpt - is_syncline_end; if (v < 0) { pissoff = pissoff_value; return; } } } is_syncline = 0; } cycles_to_add -= nextevent - currcycle; currcycle = nextevent; for (i = 0; i < ev_max; i++) { iwas1 = i; if (eventtab[i].active && eventtab[i].evtime == currcycle) { iwas2 = i; ihandled = -1; (*eventtab[i].handler)(); ihandled = 1; } } events_schedule (); } currcycle += cycles_to_add; }
void do_cycles_slow (unsigned long cycles_to_add) { if ((pissoff -= cycles_to_add) >= 0) return; cycles_to_add = -pissoff; pissoff = 0; while ((nextevent - currcycle) <= cycles_to_add) { int i; /* Keep only CPU emulation running while waiting for sync point. */ if (is_syncline > 0) { int rpt = read_processor_time (); int v = rpt - vsyncmintime; int v2 = rpt - is_syncline_end; if (v > vsynctimebase || v < -vsynctimebase) { v = 0; } if (v < 0 && v2 < 0) { pissoff = pissoff_value; return; } } else if (is_syncline < 0) { int rpt = read_processor_time (); int v = rpt - is_syncline_end; if (v < 0) { pissoff = pissoff_value; return; } is_syncline = 0; } cycles_to_add -= nextevent - currcycle; currcycle = nextevent; for (i = 0; i < ev_max; i++) { if (eventtab[i].active && eventtab[i].evtime == currcycle) { if (eventtab[i].handler == NULL) { gui_message(_T("eventtab[%d].handler is null!\n"), i); eventtab[i].active = 0; } else { (*eventtab[i].handler)(); } } } events_schedule (); } currcycle += cycles_to_add; }
static void audio_event_reset (void) { int i; last_cycles = get_cycles (); next_sample_evtime = scaled_sample_evtime; if (!isrestore ()) { for (i = 0; i < 4; i++) zerostate (audio_channel + i); } schedule_audio (); events_schedule (); }
void do_cycles_slow (unsigned long cycles_to_add) { #ifdef WITH_X86 #if 0 if (x86_turbo_on) { execute_other_cpu_single(); } #endif #endif if (!currprefs.cpu_thread) { if ((pissoff -= cycles_to_add) >= 0) return; cycles_to_add = -pissoff; pissoff = 0; } else { pissoff = 0x40000000; } while ((nextevent - currcycle) <= cycles_to_add) { if (is_syncline) { if (event_check_vsync()) return; } cycles_to_add -= nextevent - currcycle; currcycle = nextevent; for (int i = 0; i < ev_max; i++) { if (eventtab[i].active && eventtab[i].evtime == currcycle) { if (eventtab[i].handler == NULL) { gui_message(_T("eventtab[%d].handler is null!\n"), i); eventtab[i].active = 0; } else { (*eventtab[i].handler)(); } } } events_schedule (); } currcycle += cycles_to_add; }
void MISC_handler (void) { static bool dorecheck; bool recheck; int i; evt mintime; evt ct = get_cycles (); static int recursive; if (recursive) { dorecheck = true; return; } recursive++; eventtab[ev_misc].active = 0; recheck = true; while (recheck) { recheck = false; mintime = ~0L; for (i = 0; i < ev2_max; i++) { if (eventtab2[i].active) { if (eventtab2[i].evtime == ct) { eventtab2[i].active = false; event2_count--; eventtab2[i].handler (eventtab2[i].data); if (dorecheck || eventtab2[i].active) { recheck = true; dorecheck = false; } } else { evt eventtime = eventtab2[i].evtime - ct; if (eventtime < mintime) mintime = eventtime; } } } } if (mintime != ~0UL) { eventtab[ev_misc].active = true; eventtab[ev_misc].oldcycles = ct; eventtab[ev_misc].evtime = ct + mintime; events_schedule (); } recursive--; }