mirror of
https://github.com/holub/mame
synced 2025-07-06 02:18:09 +03:00
improve armadillo control
This commit is contained in:
parent
2c7397d1d9
commit
c1e2d21c46
@ -3012,37 +3012,63 @@ MACHINE_CONFIG_END
|
|||||||
TIMER_CALLBACK_MEMBER(namcos22_state::adillor_trackball_interrupt)
|
TIMER_CALLBACK_MEMBER(namcos22_state::adillor_trackball_interrupt)
|
||||||
{
|
{
|
||||||
generic_pulse_irq_line(m_mcu, param ? M37710_LINE_TIMERA2TICK : M37710_LINE_TIMERA3TICK, 1);
|
generic_pulse_irq_line(m_mcu, param ? M37710_LINE_TIMERA2TICK : M37710_LINE_TIMERA3TICK, 1);
|
||||||
m_ar_tb_interrupt[param]->adjust(m_ar_tb_reload[param], param);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMER_DEVICE_CALLBACK_MEMBER(namcos22_state::adillor_trackball_update)
|
TIMER_DEVICE_CALLBACK_MEMBER(namcos22_state::adillor_trackball_update)
|
||||||
{
|
{
|
||||||
// arbitrary timer for reading trackball
|
// arbitrary timer for reading optical trackball
|
||||||
for (int axis = 0; axis < 2; axis++)
|
UINT8 ix = ioport("TRACKX")->read();
|
||||||
|
UINT8 iy = ioport("TRACKY")->read();
|
||||||
|
|
||||||
|
if (ix != 0x80 || iy < 0x80)
|
||||||
{
|
{
|
||||||
UINT16 ipt = ioport(axis ? "TRACKY" : "TRACKX")->read();
|
if (iy >= 0x80)
|
||||||
if (ipt > 0 && ipt < 0x8000)
|
iy = 0x7f;
|
||||||
|
double x = (double)(ix - 0x80) / 127.0;
|
||||||
|
double y = (double)(0x80 - iy) / 127.0;
|
||||||
|
|
||||||
|
// normalize
|
||||||
|
double a = atan(x/y);
|
||||||
|
double p = sqrt(x*x + y*y);
|
||||||
|
double v = (fabs(a) < (M_PI / 4.0)) ? p*cos(a) : p*sin(a);
|
||||||
|
v = fabs(v);
|
||||||
|
|
||||||
|
// note that it is rotated by 45 degrees, so instead of axes like (+), they are like (x)
|
||||||
|
a += (M_PI / 4.0);
|
||||||
|
if (a < 0)
|
||||||
|
a = 0;
|
||||||
|
else if (a > (M_PI / 2.0))
|
||||||
|
a = M_PI / 2.0;
|
||||||
|
|
||||||
|
// tied to mcu A2/A3 timer (speed determines frequency)
|
||||||
|
// these values(in usec) may need tweaking:
|
||||||
|
const int base = 1000;
|
||||||
|
const int range = 5000;
|
||||||
|
|
||||||
|
double t[2];
|
||||||
|
t[0] = v*sin(a); // y -> A2
|
||||||
|
t[1] = v*cos(a); // x -> A3
|
||||||
|
|
||||||
|
for (int axis = 0; axis < 2; axis++)
|
||||||
{
|
{
|
||||||
// optical trackball, tied to mcu A2/A3 timer (speed determines frequency)
|
if (t[axis] > (1.0 / (double)(range)))
|
||||||
// note that it is rotated by 45 degrees, so instead of axes like (+), they are like (x)
|
{
|
||||||
// (not yet tested on a real trackball, values below still need to be tweaked)
|
attotime freq = attotime::from_usec((base + range) - ((double)(range) * t[axis]));
|
||||||
const int cap = 256;
|
m_ar_tb_interrupt[axis]->adjust(min(freq, m_ar_tb_interrupt[axis]->remaining()), axis, freq);
|
||||||
const int maxspeed = 500;
|
}
|
||||||
const int sensitivity = 50;
|
else
|
||||||
|
{
|
||||||
if (ipt > cap) ipt = cap;
|
// not moving
|
||||||
ipt = cap - ipt;
|
m_ar_tb_interrupt[axis]->adjust(attotime::never, axis, attotime::never);
|
||||||
|
}
|
||||||
attotime freq = attotime::from_usec(maxspeed + sensitivity * ipt);
|
|
||||||
m_ar_tb_reload[axis] = freq;
|
|
||||||
m_ar_tb_interrupt[axis]->adjust(min(freq, m_ar_tb_interrupt[axis]->remaining()), axis);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// both axes not moving
|
||||||
|
for (int axis = 0; axis < 2; axis++)
|
||||||
{
|
{
|
||||||
// backwards or not moving
|
m_ar_tb_interrupt[axis]->adjust(attotime::never, axis, attotime::never);
|
||||||
m_ar_tb_reload[axis] = attotime::never;
|
|
||||||
m_ar_tb_interrupt[axis]->adjust(attotime::never, axis);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5211,10 +5237,10 @@ static INPUT_PORTS_START( adillor )
|
|||||||
PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||||
|
|
||||||
PORT_START("TRACKX")
|
PORT_START("TRACKX")
|
||||||
PORT_BIT( 0xffff, 0x0000, IPT_TRACKBALL_X ) PORT_SENSITIVITY(100) PORT_KEYDELTA(200) PORT_RESET
|
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_MINMAX(0x01, 0xff) PORT_SENSITIVITY(100) PORT_KEYDELTA(20)
|
||||||
|
|
||||||
PORT_START("TRACKY")
|
PORT_START("TRACKY")
|
||||||
PORT_BIT( 0xffff, 0x0000, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(200) PORT_RESET PORT_REVERSE
|
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0x01, 0xff) PORT_SENSITIVITY(100) PORT_KEYDELTA(20)
|
||||||
INPUT_PORTS_END /* Armadillo Racing */
|
INPUT_PORTS_END /* Armadillo Racing */
|
||||||
|
|
||||||
static INPUT_PORTS_START( propcycl )
|
static INPUT_PORTS_START( propcycl )
|
||||||
|
@ -78,7 +78,6 @@ public:
|
|||||||
optional_shared_ptr<UINT32> m_czram;
|
optional_shared_ptr<UINT32> m_czram;
|
||||||
|
|
||||||
int m_bEnableDspIrqs;
|
int m_bEnableDspIrqs;
|
||||||
attotime m_ar_tb_reload[2];
|
|
||||||
emu_timer *m_ar_tb_interrupt[2];
|
emu_timer *m_ar_tb_interrupt[2];
|
||||||
UINT16 m_MasterBIOZ;
|
UINT16 m_MasterBIOZ;
|
||||||
UINT32 *m_pPointRAM;
|
UINT32 *m_pPointRAM;
|
||||||
|
Loading…
Reference in New Issue
Block a user