Previous 199869 Revisions Next

r29553 Saturday 12th April, 2014 at 03:35:23 UTC by R. Belmont
(MESS) apple3: preliminary joystick support [R. Belmont]
[src/mess/drivers]apple3.c
[src/mess/includes]apple3.h
[src/mess/machine]apple3.c

trunk/src/mess/includes/apple3.h
r29552r29553
5050      m_speaker(*this, SPEAKER_TAG),
5151      m_dac(*this, DAC_TAG),
5252      m_kbspecial(*this, "keyb_special"),
53      m_palette(*this, "palette")
53      m_palette(*this, "palette"),
54      m_joy1x(*this, "joy_1_x"),
55      m_joy1y(*this, "joy_1_y"),
56      m_joy2x(*this, "joy_2_x"),
57      m_joy2y(*this, "joy_2_y"),
58      m_joybuttons(*this, "joy_buttons"),
59      m_pdltimer(*this, "pdltimer")
5460   {
5561   }
5662
r29552r29553
6773   required_device<dac_device> m_dac;
6874   required_ioport m_kbspecial;
6975   required_device<palette_device> m_palette;
76   required_ioport m_joy1x, m_joy1y, m_joy2x, m_joy2y, m_joybuttons;
77   required_device<timer_device> m_pdltimer;
7078
7179   DECLARE_READ8_MEMBER(apple3_memory_r);
7280   DECLARE_WRITE8_MEMBER(apple3_memory_w);
r29552r29553
107115   DECLARE_READ_LINE_MEMBER(ay3600_control_r);
108116   DECLARE_WRITE_LINE_MEMBER(ay3600_data_ready_w);
109117   void apple3_postload();
118   TIMER_DEVICE_CALLBACK_MEMBER(paddle_timer);
119   void pdl_handler(int offset);
110120
111121   // these need to be public for now
112122   UINT32 m_flags;
r29552r29553
137147   int m_c040_time;
138148   UINT16 m_lastchar, m_strobe;
139149   UINT8 m_transchar;
150
151   int m_analog_sel;
152   bool m_ramp_active;
153   int m_pdl_charge;
140154};
141155
142156
trunk/src/mess/drivers/apple3.c
r29552r29553
121121   MCFG_RS232_DSR_HANDLER(DEVWRITELINE("acia", mos6551_device, write_dsr))
122122   // TODO: remove cts kludge from machine/apple3.c and come up with a good way of coping with pull up resistors.
123123
124   /* paddle */
125   MCFG_TIMER_DRIVER_ADD("pdltimer", apple3_state, paddle_timer);
126
124127   /* rtc */
125128   MCFG_DEVICE_ADD("rtc", MM58167, XTAL_32_768kHz)
126129
127130   /* via */
128   MCFG_DEVICE_ADD("via6522_0", VIA6522, 1000000)
131   MCFG_DEVICE_ADD("via6522_0", VIA6522, 2000000)
129132   MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(apple3_state, apple3_via_0_out_a))
130133   MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(apple3_state, apple3_via_0_out_b))
131134   MCFG_VIA6522_IRQ_HANDLER(WRITELINE(apple3_state, apple3_via_0_irq_func))
r29552r29553
313316   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Open Apple")   PORT_CODE(KEYCODE_LALT)
314317   PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple")  PORT_CODE(KEYCODE_RALT)
315318   PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET")        PORT_CODE(KEYCODE_F12)
319
320   PORT_START("joy_1_x")      /* Joystick 1 X Axis */
321   PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_NAME("P1 Joystick X")
322   PORT_MINMAX(0, 0xff) PORT_PLAYER(1)
323
324   PORT_START("joy_1_y")      /* Joystick 1 Y Axis */
325   PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_NAME("P1 Joystick Y")
326   PORT_MINMAX(0,0xff) PORT_PLAYER(1)
327
328   PORT_START("joy_2_x")      /* Joystick 2 X Axis */
329   PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_NAME("P2 Joystick X")
330   PORT_MINMAX(0,0xff) PORT_PLAYER(2)
331
332   PORT_START("joy_2_y")      /* Joystick 2 Y Axis */
333   PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_NAME("P2 Joystick Y")
334   PORT_MINMAX(0,0xff) PORT_PLAYER(2)
335
336   PORT_START("joy_buttons")
337   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(1) PORT_NAME("Joystick 1 Button 1")
338   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(1) PORT_NAME("Joystick 1 Button 2")
339   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(2) PORT_NAME("Joystick 2 Button 1")
340   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(2) PORT_NAME("Joystick 2 Button 2")
316341INPUT_PORTS_END
317342
318343ROM_START(apple3)
trunk/src/mess/machine/apple3.c
r29552r29553
3939            bits 0-5: 6-bit audio DAC output
4040            bit 6: screen blank
4141            bit 7: OR of NMI from slots
42
42
4343***************************************************************************/
4444
4545#include "emu.h"
r29552r29553
150150            m_flags &= ~(1 << ((offset - 0x50) / 2));
151151         break;
152152
153      case 0x60: case 0x61: case 0x62: case 0x63:
154      case 0x64: case 0x65: case 0x66: case 0x67:
155      case 0x68: case 0x69: case 0x6A: case 0x6B:
156      case 0x6C: case 0x6D: case 0x6E: case 0x6F:
157         /* unsure what these are */
158         result = 0x00;
153      case 0x58:
154      case 0x59:
155      case 0x5a:
156      case 0x5b:
157      case 0x5c:
158      case 0x5d:
159      case 0x5e:
160      case 0x5f:
161         pdl_handler(offset);
159162         break;
160163
164      case 0x60:   // joystick switch 0
165      case 0x68:
166         result = (m_joybuttons->read() & 1) ? 0x80 : 0x00;
167         break;
168
169      case 0x61:   // joystick switch 1 (margin switch for Silentype)
170      case 0x69:
171         result = (m_joybuttons->read() & 4) ? 0x80 : 0x00;
172         break;
173
174      case 0x62:   // joystick switch 2
175      case 0x6a:
176         result = (m_joybuttons->read() & 2) ? 0x80 : 0x00;
177         break;
178
179      case 0x63:   // joystick switch 3 (serial clock for silentype)
180      case 0x6b:
181         result = (m_joybuttons->read() & 8) ? 0x80 : 0x00;
182         break;
183
184      case 0x66:   // paddle A/D conversion done (bit 7 = 1 while counting, 0 when done)
185      case 0x6e:
186         return m_ramp_active ? 0x80 : 0x00;
187         break;
188
161189      case 0x70: case 0x71: case 0x72: case 0x73:
162190      case 0x74: case 0x75: case 0x76: case 0x77:
163191      case 0x78: case 0x79: case 0x7A: case 0x7B:
r29552r29553
246274WRITE8_MEMBER(apple3_state::apple3_c0xx_w)
247275{
248276   device_a2bus_card_interface *slotdevice;
277   UINT8 pdlread;
249278
250279   switch(offset)
251280   {
r29552r29553
287316            m_flags &= ~(1 << ((offset - 0x50) / 2));
288317         break;
289318
319      case 0x58:
320      case 0x59:
321      case 0x5a:
322      case 0x5b:
323      case 0x5c:
324      case 0x5d:
325      case 0x5e:
326      case 0x5f:
327         pdl_handler(offset);
328         break;
290329
291330      case 0x70: case 0x71: case 0x72: case 0x73:
292331      case 0x74: case 0x75: case 0x76: case 0x77:
r29552r29553
582621   m_lastchar = 0x0d;
583622   m_rom_has_been_disabled = false;
584623   m_cnxx_slot = -1;
624   m_analog_sel = 0;
625   m_ramp_active = false;
585626}
586627
587628
r29552r29553
715756   save_item(NAME(m_transchar));
716757   save_item(NAME(m_flags));
717758   save_item(NAME(m_char_mem));
759   save_item(NAME(m_analog_sel));
760   save_item(NAME(m_ramp_active));
761   save_item(NAME(m_pdl_charge));
718762
719763   machine().save().register_postload(save_prepost_delegate(FUNC(apple3_state::apple3_postload), this));
720764}
r29552r29553
11521196      }
11531197   }
11541198}
1199
1200void apple3_state::pdl_handler(int offset)
1201{
1202   UINT8 pdlread;
1203
1204   switch (offset)
1205   {
1206      case 0x58:
1207         m_analog_sel &= ~1;
1208         break;
1209
1210      case 0x59:
1211         m_analog_sel |= 1;
1212         break;
1213
1214      case 0x5a:
1215         m_analog_sel &= ~4;
1216         break;
1217
1218      case 0x5b:
1219         m_analog_sel |= 4;
1220         break;
1221
1222      case 0x5c:
1223         m_ramp_active = false;
1224         m_pdl_charge = 0;
1225         m_pdltimer->adjust(attotime::from_hz(1000000.0));
1226         break;
1227
1228      case 0x5d:
1229         switch (m_analog_sel)
1230         {
1231            case 1:
1232               pdlread = m_joy1x->read();
1233               break;
1234
1235            case 2:
1236               pdlread = m_joy1y->read();
1237               break;
1238
1239            case 4:
1240               pdlread = m_joy2x->read();
1241               break;
1242
1243            case 5:
1244               pdlread = m_joy2y->read();
1245               break;
1246
1247            default:
1248               pdlread = 127;
1249               break;
1250         }
1251
1252         // help the ROM self-test
1253         if (m_pdl_charge > 82)
1254         {
1255            m_pdl_charge += (pdlread*4);
1256            m_pdl_charge -= 93;
1257         }
1258         m_pdltimer->adjust(attotime::from_hz(1000000.0));
1259         m_ramp_active = true;
1260         break;
1261
1262      case 0x5e:
1263         m_analog_sel &= ~2;
1264         break;
1265
1266      case 0x5f:
1267         m_analog_sel |= 2;
1268         break;
1269   }
1270}
1271
1272TIMER_DEVICE_CALLBACK_MEMBER(apple3_state::paddle_timer)
1273{
1274   if (m_ramp_active)
1275   {
1276      m_pdl_charge--;
1277
1278      if (m_pdl_charge > 0)
1279      {
1280         m_pdltimer->adjust(attotime::from_hz(1000000.0));
1281      }
1282      else
1283      {
1284         m_pdltimer->adjust(attotime::never);
1285         m_ramp_active = false;
1286      }
1287   }
1288   else
1289   {
1290      m_pdl_charge++;
1291      m_pdltimer->adjust(attotime::from_hz(1000000.0));
1292   }
1293}
1294

Previous 199869 Revisions Next


© 1997-2024 The MAME Team