joystick port 1 button 2 is input for button state */
| 4049 | |
| 4050 | /* joystick port 1 button 2 is input for button state */ |
| 4051 | static uae_u16 handle_joystick_potgor (uae_u16 potgor) |
| 4052 | { |
| 4053 | int i; |
| 4054 | |
| 4055 | cap_check(false); |
| 4056 | for (i = 0; i < 2; i++) { |
| 4057 | uae_u16 p9dir = 0x0800 << (i * 4); /* output enable P9 */ |
| 4058 | uae_u16 p9dat = 0x0400 << (i * 4); /* data P9 */ |
| 4059 | uae_u16 p5dir = 0x0200 << (i * 4); /* output enable P5 */ |
| 4060 | uae_u16 p5dat = 0x0100 << (i * 4); /* data P5 */ |
| 4061 | |
| 4062 | if (cd32_pad_enabled[i] && cd32padmode(i)) { |
| 4063 | |
| 4064 | /* p5 is floating in input-mode */ |
| 4065 | potgor &= ~p5dat; |
| 4066 | if (pot_cap[i][0] > 100) |
| 4067 | potgor |= p5dat; |
| 4068 | |
| 4069 | if (!(potgo_value & p9dir)) |
| 4070 | potgor |= p9dat; |
| 4071 | |
| 4072 | /* shift at 1 == return one, >1 = return button states */ |
| 4073 | if (cd32_shifter[i] == 0) |
| 4074 | potgor &= ~p9dat; /* shift at zero == return zero */ |
| 4075 | if (cd32_shifter[i] >= 2 && (joybutton[i] & ((1 << JOYBUTTON_CD32_PLAY) << (cd32_shifter[i] - 2)))) |
| 4076 | potgor &= ~p9dat; |
| 4077 | |
| 4078 | // normal second button pressed: always zero. Overrides CD32 mode. |
| 4079 | if (getbuttonstate(i, JOYBUTTON_2)) |
| 4080 | potgor &= ~p9dat; |
| 4081 | #ifdef ARCADIA |
| 4082 | } else if (alg_flag) { |
| 4083 | |
| 4084 | potgor = alg_potgor(potgo_value); |
| 4085 | #endif |
| 4086 | } else if (lightpen_enabled2 && lightpen_port_number() == i) { |
| 4087 | |
| 4088 | int button; |
| 4089 | |
| 4090 | if (inputdevice_get_lightpen_id() == 1) |
| 4091 | button = lightpen_trigger2; |
| 4092 | else |
| 4093 | button = getbuttonstate(i, JOYBUTTON_3); |
| 4094 | |
| 4095 | potgor |= 0x1000; |
| 4096 | if (button) |
| 4097 | potgor &= ~0x1000; |
| 4098 | |
| 4099 | } else { |
| 4100 | |
| 4101 | potgor &= ~p5dat; |
| 4102 | if (pot_cap[i][0] > 100) |
| 4103 | potgor |= p5dat; |
| 4104 | |
| 4105 | if (!cd32_pad_enabled[i] || !cd32padmode(i)) { |
| 4106 | potgor &= ~p9dat; |
| 4107 | if (pot_cap[i][1] > 100) |
| 4108 | potgor |= p9dat; |
no test coverage detected