void ReadInput( void ) { int i; if ( WaitingToQuit ) return; old_input = new_input; new_input++; if ( new_input >= INPUT_BUFFERS ) new_input = 0; ReadMouse(); ReadKeyboard(); if ( JoystickInput ) { for (i = 0; i < Num_Joysticks; i++) { if (JoystickInfo[i].connected) joystick_poll(i); } } flush_input = false; }
void joystick_process(void) { int c, d; if (joystick_type == 7) return; joystick_poll(); for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) { if (joystick_state[c].plat_joystick_nr) { int joystick_nr = joystick_state[c].plat_joystick_nr - 1; for (d = 0; d < joystick_get_axis_count(joystick_type); d++) joystick_state[c].axis[d] = joystick_get_axis(joystick_nr, joystick_state[c].axis_mapping[d]); for (d = 0; d < joystick_get_button_count(joystick_type); d++) joystick_state[c].button[d] = plat_joystick_state[joystick_nr].b[joystick_state[c].button_mapping[d]]; for (d = 0; d < joystick_get_pov_count(joystick_type); d++) { int x, y; double angle, magnitude; x = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][0]); y = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][1]); angle = (atan2((double)y, (double)x) * 360.0) / (2*M_PI); magnitude = sqrt((double)x*(double)x + (double)y*(double)y); if (magnitude < 16384) joystick_state[c].pov[d] = -1; else joystick_state[c].pov[d] = ((int)angle + 90 + 360) % 360; } } else { for (d = 0; d < joystick_get_axis_count(joystick_type); d++) joystick_state[c].axis[d] = 0; for (d = 0; d < joystick_get_button_count(joystick_type); d++) joystick_state[c].button[d] = 0; for (d = 0; d < joystick_get_pov_count(joystick_type); d++) joystick_state[c].pov[d] = -1; } } }
void runpc() { char s[200]; int done=0; startblit(); clockrate = models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed; if (is386) { if (cpu_use_dynarec) exec386_dynarec(models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed / (turbo ? 100 : 200)); else exec386(models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed / (turbo ? 100 : 200)); } else if (AT || is_nonat_286()) exec386(models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed / (turbo ? 100 : 200)); else execx86(models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed / (turbo ? 100 : 200)); keyboard_poll_host(); keyboard_process(); // checkkeys(); pollmouse(); joystick_poll(); endblit(); framecountx++; framecount++; if (framecountx>=100) { pclog("onesec\n"); framecountx=0; mips=(float)insc/1000000.0f; insc=0; flops=(float)fpucount/1000000.0f; fpucount=0; sreadlnum=readlnum; swritelnum=writelnum; segareads=egareads; segawrites=egawrites; scycles_lost = cycles_lost; cpu_recomp_blocks_latched = cpu_recomp_blocks; cpu_recomp_ins_latched = cpu_recomp_ins; cpu_recomp_full_ins_latched = cpu_recomp_full_ins; cpu_new_blocks_latched = cpu_new_blocks; cpu_recomp_flushes_latched = cpu_recomp_flushes; cpu_recomp_evicted_latched = cpu_recomp_evicted; cpu_recomp_reuse_latched = cpu_recomp_reuse; cpu_recomp_removed_latched = cpu_recomp_removed; cpu_reps_latched = cpu_reps; cpu_notreps_latched = cpu_notreps; cpu_recomp_blocks = 0; cpu_recomp_ins = 0; cpu_recomp_full_ins = 0; cpu_new_blocks = 0; cpu_recomp_flushes = 0; cpu_recomp_evicted = 0; cpu_recomp_reuse = 0; cpu_recomp_removed = 0; cpu_reps = 0; cpu_notreps = 0; updatestatus=1; readlnum=writelnum=0; egareads=egawrites=0; cycles_lost = 0; mmuflush=0; intcount=0; intcount=pitcount=0; emu_fps = frames; frames = 0; } if (win_title_update) { win_title_update=0; if (is386) { if (cpu_use_dynarec) sprintf(s, "PCem-X v10 [DYN] - %i%% - %s - %s - %s", fps, model_getname(), models[model].cpu[cpu_manufacturer].cpus[cpu].name, (!mousecapture) ? "Click to capture mouse" : "Press CTRL-END or middle button to release mouse"); else sprintf(s, "PCem-X v10 [INT 286/386] - %i%% - %s - %s - %s", fps, model_getname(), models[model].cpu[cpu_manufacturer].cpus[cpu].name, (!mousecapture) ? "Click to capture mouse" : "Press CTRL-END or middle button to release mouse"); } else if (AT || is_nonat_286()) sprintf(s, "PCem-X v10 [INT 286/386] - %i%% - %s - %s - %s", fps, model_getname(), models[model].cpu[cpu_manufacturer].cpus[cpu].name, (!mousecapture) ? "Click to capture mouse" : "Press CTRL-END or middle button to release mouse"); else sprintf(s, "PCem-X v10 [INT 808x] - %i%% - %s - %s - %s", fps, model_getname(), models[model].cpu[cpu_manufacturer].cpus[cpu].name, (!mousecapture) ? "Click to capture mouse" : "Press CTRL-END or middle button to release mouse"); set_window_title(s); } done++; frame++; }