struct vidbuf_description *vidinfo = &adisplays[monid].gfxvidinfo;
const char *p;
int color1 = onscreen ? (lpnum ? 0x0ff : 0xff0) : (lpnum ? 0x0f0 : 0xf00);
- int color2 = 0x000;
+ int color2 = (color1 & 0xeee) >> 1;
xlinebuffer = vidinfo->drawbuffer.linemem;
if (xlinebuffer == 0)
for (int i = 0; i < LIGHTPEN_WIDTH; i++) {
int xx = x + i - LIGHTPEN_WIDTH / 2;
if (*p != '-' && xx >= 0 && xx < vidinfo->drawbuffer.outwidth) {
- putpixel (xlinebuffer, xlinebuffer_genlock, vidinfo->drawbuffer.pixbytes, xx, *p == 'x' ? xcolors[color1] : xcolors[color2], 1);
+ putpixel(xlinebuffer, xlinebuffer_genlock, vidinfo->drawbuffer.pixbytes, xx, *p == 'x' ? xcolors[color1] : xcolors[color2], 1);
}
p++;
}
if (cy >= maxvpos)
cy = maxvpos - 1;
- for (int i = 0; i < LIGHTPEN_HEIGHT; i++) {
- int line = lightpen_y[lpnum] + i - LIGHTPEN_HEIGHT / 2;
- if (line >= 0 || line < max_ypos_thisframe) {
- if (lightpen_active > 0 && currprefs.lightpen_crosshair) {
- draw_lightpen_cursor(vb->monitor_id, lightpen_x[lpnum], i, line, cx > 0, lpnum);
+ if (currprefs.lightpen_crosshair && lightpen_active) {
+ for (int i = 0; i < LIGHTPEN_HEIGHT; i++) {
+ int line = lightpen_y[lpnum] + i - LIGHTPEN_HEIGHT / 2;
+ if (line >= 0 && line < max_ypos_thisframe) {
+ if (lightpen_active & (1 << lpnum)) {
+ draw_lightpen_cursor(vb->monitor_id, lightpen_x[lpnum], i, line, cx > 0, lpnum);
+ }
}
}
}
lightpen_cx[lpnum] = cx;
lightpen_cy[lpnum] = cy;
-
- if (lightpen_active < 0)
- lightpen_active = 0;
}
static void refresh_indicator_init(void)
}
if (lightpen_active) {
- lightpen_update(vb, 0);
- if (inputdevice_get_lightpen_id() >= 0)
+ if (lightpen_active & 1) {
+ lightpen_update(vb, 0);
+ }
+ if (inputdevice_get_lightpen_id() >= 0 && (lightpen_active & 2)) {
lightpen_update(vb, 1);
+ }
}
if (refresh_indicator_buffer)
refresh_indicator_update(vb);
}
if (touch >= 0)
- lightpen_active = true;
+ lightpen_active |= 1;
if (touch > 0 && devid >= 0) {
setmousebuttonstate (devid, 0, 1);
end:
if (lightpen_active) {
- lightpen_active = false;
+ lightpen_active &= ~1;
if (devid >= 0)
setmousebuttonstate (devid, 0, 0);
}
pot_cap[joy][idx] = 511;
}
-static void cap_check (void)
+static void cap_check(bool hsync)
{
int joy, i;
for (joy = 0; joy < 2; joy++) {
for (i = 0; i < 2; i++) {
+ bool cancharge = true;
int charge = 0, dong, joypot;
uae_u16 pdir = 0x0200 << (joy * 4 + i * 2); /* output enable */
uae_u16 pdat = 0x0100 << (joy * 4 + i * 2); /* data */
charge = 1; // slow charge via pull-up resistor
}
if (!(potgo_value & pdir)) { // input?
- if (pot_dat_act[joy][i])
+ if (pot_dat_act[joy][i] && hsync) {
pot_dat[joy][i]++;
+ }
/* first 7 or 8 lines after potgo has been started = discharge cap */
if (pot_dat_act[joy][i] == 1) {
if (pot_dat[joy][i] < (currprefs.ntscmode ? POTDAT_DELAY_NTSC : POTDAT_DELAY_PAL)) {
charge = -2; /* fast discharge delay */
+ cancharge = hsync;
} else {
pot_dat_act[joy][i] = 2;
pot_dat[joy][i] = 0;
pot_dat_act[joy][i] = 0;
}
}
+ // CD32 pad 3rd button line floating: 2-button mode
+ if (cd32_pad_enabled[joy] && i == 0) {
+ if (charge == 0)
+ charge = 2;
+ }
+ // CD32 pad in 2-button mode: blue button is internally pulled up
+ if (cd32_pad_enabled[joy] && !cd32padmode(joy) && i == 1) {
+ if (charge == 0)
+ charge = 2;
+ }
+
} else { // output?
charge = (potgo_value & pdat) ? 2 : -2; /* fast (dis)charge if output */
if (potgo_value & pdat)
pot_dat[joy][i]++; // "free running" if output+low
}
- if (isbutton)
+ if (isbutton) {
charge = -2; // button press overrides everything
+ }
if (currprefs.cs_cdtvcd) {
/* CDTV P9 is not floating */
charge = 2;
}
- // CD32 pad in 2-button mode: blue button is not floating
- if (cd32_pad_enabled[joy] && !cd32padmode(joy) && i == 1) {
- if (charge == 0)
- charge = 2;
- }
-
if (dong < 0 && charge == 0) {
if (lightpen_port[joy])
charge = 2;
}
- charge_cap (joy, i, charge);
+ if (cancharge) {
+ charge_cap(joy, i, charge);
+ }
}
}
}
int i;
maybe_read_input();
- cap_check ();
+ cap_check(false);
for (i = 0; i < 2; i++) {
int mask = 0x40 << i;
if (cd32_pad_enabled[i]) {
if (inputdevice_logging & (4 | 256)) {
write_log (_T("BFE001 W: %02X:%02X %x\n"), dra, pra, M68K_GETPC);
}
- cap_check ();
+ cap_check(false);
for (i = 0; i < 2; i++) {
uae_u8 but = 0x40 << i;
if (cd32padmode(i)) {
{
int i;
- cap_check ();
+ cap_check(false);
for (i = 0; i < 2; i++) {
uae_u16 p9dir = 0x0800 << (i * 4); /* output enable P9 */
uae_u16 p9dat = 0x0400 << (i * 4); /* data P9 */
void inputdevice_hsync (bool forceread)
{
- cap_check ();
+ cap_check(true);
#ifdef CATWEASEL
catweasel_hsync ();
{
int unit = (ie->data & 1) ? 1 : 0;
int lpnum = ie->unit - 5;
- if (lightpen_active <= 0) {
- lightpen_x[0] = vidinfo->outbuffer->outwidth / 2;
- lightpen_y[0] = vidinfo->outbuffer->outheight / 2;
- lightpen_x[1] = -1;
- lightpen_y[1] = -1;
+ if (!(lightpen_active & (1 << lpnum))) {
+ if (!state) {
+ break;
+ }
+ lightpen_x[lpnum] = vidinfo->outbuffer->outwidth / 2;
+ lightpen_y[lpnum] = vidinfo->outbuffer->outheight / 2;
+ lightpen_active |= 1 << lpnum;
}
- lightpen_active = true;
lightpen_enabled = true;
if (flags & HANDLE_IE_FLAG_ABSOLUTE) {
lastmxy_abs[lpnum][unit] = extra;
}
lightpen_enabled = false;
lightpen_enabled2 = false;
- if (lightpen_active > 0)
- lightpen_active = -1;
+ lightpen_active = 0;
for (i = 0; i < MAX_INPUT_DEVICES; i++) {
use_joysticks[i] = 0;