(MESS) apple3: preliminary joystick support [R. Belmont]

This commit is contained in:
R. Belmont 2014-04-12 03:35:23 +00:00
parent 6727feb58e
commit 2d13f17b83
3 changed files with 188 additions and 9 deletions

View File

@ -121,11 +121,14 @@ static MACHINE_CONFIG_START( apple3, apple3_state )
MCFG_RS232_DSR_HANDLER(DEVWRITELINE("acia", mos6551_device, write_dsr))
// TODO: remove cts kludge from machine/apple3.c and come up with a good way of coping with pull up resistors.
/* paddle */
MCFG_TIMER_DRIVER_ADD("pdltimer", apple3_state, paddle_timer);
/* rtc */
MCFG_DEVICE_ADD("rtc", MM58167, XTAL_32_768kHz)
/* via */
MCFG_DEVICE_ADD("via6522_0", VIA6522, 1000000)
MCFG_DEVICE_ADD("via6522_0", VIA6522, 2000000)
MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(apple3_state, apple3_via_0_out_a))
MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(apple3_state, apple3_via_0_out_b))
MCFG_VIA6522_IRQ_HANDLER(WRITELINE(apple3_state, apple3_via_0_irq_func))
@ -313,6 +316,28 @@ static INPUT_PORTS_START( apple3 )
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Open Apple") PORT_CODE(KEYCODE_LALT)
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT)
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12)
PORT_START("joy_1_x") /* Joystick 1 X Axis */
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_NAME("P1 Joystick X")
PORT_MINMAX(0, 0xff) PORT_PLAYER(1)
PORT_START("joy_1_y") /* Joystick 1 Y Axis */
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_NAME("P1 Joystick Y")
PORT_MINMAX(0,0xff) PORT_PLAYER(1)
PORT_START("joy_2_x") /* Joystick 2 X Axis */
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_NAME("P2 Joystick X")
PORT_MINMAX(0,0xff) PORT_PLAYER(2)
PORT_START("joy_2_y") /* Joystick 2 Y Axis */
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_NAME("P2 Joystick Y")
PORT_MINMAX(0,0xff) PORT_PLAYER(2)
PORT_START("joy_buttons")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(1) PORT_NAME("Joystick 1 Button 1")
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(1) PORT_NAME("Joystick 1 Button 2")
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(2) PORT_NAME("Joystick 2 Button 1")
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(2) PORT_NAME("Joystick 2 Button 2")
INPUT_PORTS_END
ROM_START(apple3)

View File

@ -50,7 +50,13 @@ public:
m_speaker(*this, SPEAKER_TAG),
m_dac(*this, DAC_TAG),
m_kbspecial(*this, "keyb_special"),
m_palette(*this, "palette")
m_palette(*this, "palette"),
m_joy1x(*this, "joy_1_x"),
m_joy1y(*this, "joy_1_y"),
m_joy2x(*this, "joy_2_x"),
m_joy2y(*this, "joy_2_y"),
m_joybuttons(*this, "joy_buttons"),
m_pdltimer(*this, "pdltimer")
{
}
@ -67,6 +73,8 @@ public:
required_device<dac_device> m_dac;
required_ioport m_kbspecial;
required_device<palette_device> m_palette;
required_ioport m_joy1x, m_joy1y, m_joy2x, m_joy2y, m_joybuttons;
required_device<timer_device> m_pdltimer;
DECLARE_READ8_MEMBER(apple3_memory_r);
DECLARE_WRITE8_MEMBER(apple3_memory_w);
@ -107,6 +115,8 @@ public:
DECLARE_READ_LINE_MEMBER(ay3600_control_r);
DECLARE_WRITE_LINE_MEMBER(ay3600_data_ready_w);
void apple3_postload();
TIMER_DEVICE_CALLBACK_MEMBER(paddle_timer);
void pdl_handler(int offset);
// these need to be public for now
UINT32 m_flags;
@ -137,6 +147,10 @@ private:
int m_c040_time;
UINT16 m_lastchar, m_strobe;
UINT8 m_transchar;
int m_analog_sel;
bool m_ramp_active;
int m_pdl_charge;
};

View File

@ -39,7 +39,7 @@
bits 0-5: 6-bit audio DAC output
bit 6: screen blank
bit 7: OR of NMI from slots
***************************************************************************/
#include "emu.h"
@ -150,12 +150,40 @@ READ8_MEMBER(apple3_state::apple3_c0xx_r)
m_flags &= ~(1 << ((offset - 0x50) / 2));
break;
case 0x60: case 0x61: case 0x62: case 0x63:
case 0x64: case 0x65: case 0x66: case 0x67:
case 0x68: case 0x69: case 0x6A: case 0x6B:
case 0x6C: case 0x6D: case 0x6E: case 0x6F:
/* unsure what these are */
result = 0x00;
case 0x58:
case 0x59:
case 0x5a:
case 0x5b:
case 0x5c:
case 0x5d:
case 0x5e:
case 0x5f:
pdl_handler(offset);
break;
case 0x60: // joystick switch 0
case 0x68:
result = (m_joybuttons->read() & 1) ? 0x80 : 0x00;
break;
case 0x61: // joystick switch 1 (margin switch for Silentype)
case 0x69:
result = (m_joybuttons->read() & 4) ? 0x80 : 0x00;
break;
case 0x62: // joystick switch 2
case 0x6a:
result = (m_joybuttons->read() & 2) ? 0x80 : 0x00;
break;
case 0x63: // joystick switch 3 (serial clock for silentype)
case 0x6b:
result = (m_joybuttons->read() & 8) ? 0x80 : 0x00;
break;
case 0x66: // paddle A/D conversion done (bit 7 = 1 while counting, 0 when done)
case 0x6e:
return m_ramp_active ? 0x80 : 0x00;
break;
case 0x70: case 0x71: case 0x72: case 0x73:
@ -246,6 +274,7 @@ READ8_MEMBER(apple3_state::apple3_c0xx_r)
WRITE8_MEMBER(apple3_state::apple3_c0xx_w)
{
device_a2bus_card_interface *slotdevice;
UINT8 pdlread;
switch(offset)
{
@ -287,6 +316,16 @@ WRITE8_MEMBER(apple3_state::apple3_c0xx_w)
m_flags &= ~(1 << ((offset - 0x50) / 2));
break;
case 0x58:
case 0x59:
case 0x5a:
case 0x5b:
case 0x5c:
case 0x5d:
case 0x5e:
case 0x5f:
pdl_handler(offset);
break;
case 0x70: case 0x71: case 0x72: case 0x73:
case 0x74: case 0x75: case 0x76: case 0x77:
@ -582,6 +621,8 @@ MACHINE_RESET_MEMBER(apple3_state,apple3)
m_lastchar = 0x0d;
m_rom_has_been_disabled = false;
m_cnxx_slot = -1;
m_analog_sel = 0;
m_ramp_active = false;
}
@ -715,6 +756,9 @@ DRIVER_INIT_MEMBER(apple3_state,apple3)
save_item(NAME(m_transchar));
save_item(NAME(m_flags));
save_item(NAME(m_char_mem));
save_item(NAME(m_analog_sel));
save_item(NAME(m_ramp_active));
save_item(NAME(m_pdl_charge));
machine().save().register_postload(save_prepost_delegate(FUNC(apple3_state::apple3_postload), this));
}
@ -1152,3 +1196,99 @@ WRITE_LINE_MEMBER(apple3_state::ay3600_data_ready_w)
}
}
}
void apple3_state::pdl_handler(int offset)
{
UINT8 pdlread;
switch (offset)
{
case 0x58:
m_analog_sel &= ~1;
break;
case 0x59:
m_analog_sel |= 1;
break;
case 0x5a:
m_analog_sel &= ~4;
break;
case 0x5b:
m_analog_sel |= 4;
break;
case 0x5c:
m_ramp_active = false;
m_pdl_charge = 0;
m_pdltimer->adjust(attotime::from_hz(1000000.0));
break;
case 0x5d:
switch (m_analog_sel)
{
case 1:
pdlread = m_joy1x->read();
break;
case 2:
pdlread = m_joy1y->read();
break;
case 4:
pdlread = m_joy2x->read();
break;
case 5:
pdlread = m_joy2y->read();
break;
default:
pdlread = 127;
break;
}
// help the ROM self-test
if (m_pdl_charge > 82)
{
m_pdl_charge += (pdlread*4);
m_pdl_charge -= 93;
}
m_pdltimer->adjust(attotime::from_hz(1000000.0));
m_ramp_active = true;
break;
case 0x5e:
m_analog_sel &= ~2;
break;
case 0x5f:
m_analog_sel |= 2;
break;
}
}
TIMER_DEVICE_CALLBACK_MEMBER(apple3_state::paddle_timer)
{
if (m_ramp_active)
{
m_pdl_charge--;
if (m_pdl_charge > 0)
{
m_pdltimer->adjust(attotime::from_hz(1000000.0));
}
else
{
m_pdltimer->adjust(attotime::never);
m_ramp_active = false;
}
}
else
{
m_pdl_charge++;
m_pdltimer->adjust(attotime::from_hz(1000000.0));
}
}