| 3859 | } |
| 3860 | |
| 3861 | static void cap_check(bool hsync) |
| 3862 | { |
| 3863 | for (int joy = 0; joy < 2; joy++) { |
| 3864 | for (int i = 0; i < 2; i++) { |
| 3865 | bool cancharge = true; |
| 3866 | int charge = 0, dong, joypot; |
| 3867 | uae_u16 pdir = 0x0200 << (joy * 4 + i * 2); /* output enable */ |
| 3868 | uae_u16 pdat = 0x0100 << (joy * 4 + i * 2); /* data */ |
| 3869 | uae_u16 p5dir = 0x0200 << (joy * 4); |
| 3870 | uae_u16 p5dat = 0x0100 << (joy * 4); |
| 3871 | int isbutton = getbuttonstate (joy, i == 0 ? JOYBUTTON_3 : JOYBUTTON_2); |
| 3872 | |
| 3873 | if (cd32_pad_enabled[joy] && !cd32padmode(joy)) { |
| 3874 | // only red and blue can be read if CD32 pad and only if it is in normal pad mode |
| 3875 | isbutton |= getbuttonstate (joy, JOYBUTTON_CD32_BLUE); |
| 3876 | // middle button line is floating |
| 3877 | if (i == 0) |
| 3878 | isbutton = 0; |
| 3879 | cd32_shifter[joy] = 8; |
| 3880 | } |
| 3881 | |
| 3882 | // two lightpens use multiplexer chip |
| 3883 | if (lightpen_enabled2 && lightpen_port_number() == joy) |
| 3884 | continue; |
| 3885 | |
| 3886 | dong = dongle_analogjoy (joy, i); |
| 3887 | if (dong >= 0) { |
| 3888 | isbutton = 0; |
| 3889 | joypot = dong; |
| 3890 | if (pot_cap[joy][i] < joypot) |
| 3891 | charge = 1; // slow charge via dongle resistor |
| 3892 | } else { |
| 3893 | joypot = joydirpot[joy][i]; |
| 3894 | if (analog_port[joy][i] && pot_cap[joy][i] < joypot) |
| 3895 | charge = 1; // slow charge via pot variable resistor |
| 3896 | if ((is_joystick_pullup (joy) && digital_port[joy][i]) || (is_mouse_pullup (joy) && mouse_port[joy])) |
| 3897 | charge = 1; // slow charge via pull-up resistor |
| 3898 | } |
| 3899 | if (!(potgo_value & pdir)) { // input? |
| 3900 | if (pot_dat_act[joy][i] && hsync) { |
| 3901 | pot_dat[joy][i]++; |
| 3902 | } |
| 3903 | /* first 8 lines after potgo has been started = discharge cap */ |
| 3904 | if (pot_dat_act[joy][i] == 1) { |
| 3905 | if (pot_dat[joy][i] < POTDAT_DELAY) { |
| 3906 | charge = -2; /* fast discharge delay */ |
| 3907 | cancharge = hsync; |
| 3908 | } else { |
| 3909 | pot_dat_act[joy][i] = 2; |
| 3910 | pot_dat[joy][i] = 0; |
| 3911 | } |
| 3912 | } |
| 3913 | if (dong >= 0) { |
| 3914 | if (pot_dat_act[joy][i] == 2 && pot_cap[joy][i] >= joypot) |
| 3915 | pot_dat_act[joy][i] = 0; |
| 3916 | } else { |
| 3917 | if (analog_port[joy][i] && pot_dat_act[joy][i] == 2 && pot_cap[joy][i] >= joypot) |
| 3918 | pot_dat_act[joy][i] = 0; |
no test coverage detected