Previous 199869 Revisions Next

r20546 Sunday 27th January, 2013 at 19:10:53 UTC by Curt Coder
(MESS) vic10: Cleaned up input handling. Controllers are now connected using the slot interface, and by default a joystick in port 2 is present. [Curt Coder]
[src/mess/drivers]vic10.c
[src/mess/includes]vic10.h

trunk/src/mess/drivers/vic10.c
r20545r20546
2323
2424void vic10_state::check_interrupts()
2525{
26   m_maincpu->set_input_line(INPUT_LINE_IRQ0, m_cia_irq | m_vic_irq | m_exp_irq);
26   m_maincpu->set_input_line(INPUT_LINE_IRQ0, m_cia_irq || m_vic_irq || m_exp_irq);
2727}
2828
2929
r20545r20546
185185//-------------------------------------------------
186186
187187static INPUT_PORTS_START( vic10 )
188   PORT_INCLUDE( common_cbm_keyboard )     // ROW0 -> ROW7
188   PORT_START( "ROW0" )
189   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Crsr Down Up") PORT_CODE(KEYCODE_RALT)        PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(UCHAR_MAMEKEY(UP))
190   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3)                                    PORT_CHAR(UCHAR_MAMEKEY(F5))
191   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2)                                    PORT_CHAR(UCHAR_MAMEKEY(F3))
192   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1)                                    PORT_CHAR(UCHAR_MAMEKEY(F1))
193   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4)                                    PORT_CHAR(UCHAR_MAMEKEY(F7))
194   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Crsr Right Left") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
195   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER)             PORT_CHAR(13)
196   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("INST DEL") PORT_CODE(KEYCODE_BACKSPACE)       PORT_CHAR(8) PORT_CHAR(UCHAR_MAMEKEY(INSERT))
189197
190   PORT_INCLUDE( c64_special )             // SPECIAL
198   PORT_START( "ROW1" )
199   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Shift (Left)") PORT_CODE(KEYCODE_LSHIFT)      PORT_CHAR(UCHAR_SHIFT_1)
200   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E)         PORT_CHAR('E')
201   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S)         PORT_CHAR('S')
202   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z)         PORT_CHAR('Z')
203   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4)         PORT_CHAR('4') PORT_CHAR('$')
204   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A)         PORT_CHAR('A')
205   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W)         PORT_CHAR('W')
206   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3)         PORT_CHAR('3') PORT_CHAR('#')
191207
192   PORT_INCLUDE( c64_controls )            // CTRLSEL, JOY0, JOY1, PADDLE0 -> PADDLE3, TRACKX, TRACKY, LIGHTX, LIGHTY, OTHER
208   PORT_START( "ROW2" )
209   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X)         PORT_CHAR('X')
210   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T)         PORT_CHAR('T')
211   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F)         PORT_CHAR('F')
212   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C)         PORT_CHAR('C')
213   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6)         PORT_CHAR('6') PORT_CHAR('&')
214   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D)         PORT_CHAR('D')
215   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R)         PORT_CHAR('R')
216   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5)         PORT_CHAR('5') PORT_CHAR('%')
217
218   PORT_START( "ROW3" )
219   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V)         PORT_CHAR('V')
220   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U)         PORT_CHAR('U')
221   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H)         PORT_CHAR('H')
222   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B)         PORT_CHAR('B')
223   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8)         PORT_CHAR('8') PORT_CHAR('(')
224   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G)         PORT_CHAR('G')
225   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y)         PORT_CHAR('Y')
226   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7)         PORT_CHAR('7') PORT_CHAR('\'')
227
228   PORT_START( "ROW4" )
229   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N)         PORT_CHAR('N')
230   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O)         PORT_CHAR('O')
231   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K)         PORT_CHAR('K')
232   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M)         PORT_CHAR('M')
233   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0)         PORT_CHAR('0')
234   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J)         PORT_CHAR('J')
235   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I)         PORT_CHAR('I')
236   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9)         PORT_CHAR('9') PORT_CHAR(')')
237
238   PORT_START( "ROW5" )
239   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA)     PORT_CHAR(',') PORT_CHAR('<')
240   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@')
241   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON)     PORT_CHAR(':') PORT_CHAR('[')
242   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP)      PORT_CHAR('.') PORT_CHAR('>')
243   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS)    PORT_CHAR('-')
244   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L)         PORT_CHAR('L')
245   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P)         PORT_CHAR('P')
246   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS)     PORT_CHAR('+')
247
248   PORT_START( "ROW6" )
249   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH)                             PORT_CHAR('/') PORT_CHAR('?')
250   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91  Pi") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0x2191) PORT_CHAR(0x03C0)
251   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH)                         PORT_CHAR('=')
252   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Shift (Right)") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
253   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("CLR HOME") PORT_CODE(KEYCODE_INSERT)      PORT_CHAR(UCHAR_MAMEKEY(HOME))
254   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE)                             PORT_CHAR(';') PORT_CHAR(']')
255   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)                        PORT_CHAR('*')
256   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2)                        PORT_CHAR('\xA3')
257
258   PORT_START( "ROW7" )
259   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RUN STOP") PORT_CODE(KEYCODE_HOME)
260   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q)                                 PORT_CHAR('Q')
261   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("CBM") PORT_CODE(KEYCODE_LALT)
262   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE)                             PORT_CHAR(' ')
263   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2)                                 PORT_CHAR('2') PORT_CHAR('"')
264   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB)                               PORT_CHAR(UCHAR_SHIFT_2)
265   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_TILDE)   PORT_CHAR(0x2190)
266   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1)                                 PORT_CHAR('1') PORT_CHAR('!')
267
268   PORT_START( "RESTORE" )
269   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RESTORE") PORT_CODE(KEYCODE_PRTSCR)
270
271   PORT_START( "LOCK" )
272   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("SHIFT LOCK") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
273   PORT_BIT( 0x7f, IP_ACTIVE_LOW, IPT_UNUSED )
193274INPUT_PORTS_END
194275
195276
r20545r20546
202283//  vic2_interface vic_intf
203284//-------------------------------------------------
204285
205INTERRUPT_GEN_MEMBER(vic10_state::vic10_frame_interrupt)
206{
207   cbm_common_interrupt(&device);
208}
209
210286WRITE_LINE_MEMBER( vic10_state::vic_irq_w )
211287{
212288   m_vic_irq = state;
r20545r20546
237313   {
238314   case 1: data = m_joy1->pot_x_r(); break;
239315   case 2: data = m_joy2->pot_x_r(); break;
240   case 3: break; // TODO pot1 and pot2 in series
316   case 3:
317      if (m_joy1->has_pot_x() && m_joy2->has_pot_x())
318      {
319         data = 1 / (1 / m_joy1->pot_x_r() + 1 / m_joy2->pot_x_r());
320      }
321      else if (m_joy1->has_pot_x())
322      {
323         data = m_joy1->pot_x_r();
324      }
325      else if (m_joy2->has_pot_x())
326      {
327         data = m_joy2->pot_x_r();
328      }
329      break;
241330   }
242331
243332   return data;
r20545r20546
251340   {
252341   case 1: data = m_joy1->pot_y_r(); break;
253342   case 2: data = m_joy2->pot_y_r(); break;
254   case 3: break; // TODO pot1 and pot2 in series
343   case 3:
344      if (m_joy1->has_pot_y() && m_joy2->has_pot_y())
345      {
346         data = 1 / (1 / m_joy1->pot_y_r() + 1 / m_joy2->pot_y_r());
347      }
348      else if (m_joy1->has_pot_y())
349      {
350         data = m_joy1->pot_y_r();
351      }
352      else if (m_joy2->has_pot_y())
353      {
354         data = m_joy2->pot_y_r();
355      }
356      break;
255357   }
256358
257359   return data;
r20545r20546
292394
293395   */
294396
295   UINT8 cia0portb = m_cia->pb_r();
397   UINT8 data = 0xff;
296398
297   return cbm_common_cia0_port_a_r(m_cia, cia0portb);
399   // joystick
400   UINT8 joy_b = m_joy2->joy_r();
401
402   data &= (0xf0 | (joy_b & 0x0f));
403   data &= ~(!BIT(joy_b, 5) << 4);
404
405   // keyboard
406   UINT8 cia_pb = m_cia->pb_r();
407   UINT8 row[8] = { m_row0->read(), m_row1->read() & m_lock->read(), m_row2->read(), m_row3->read(),
408                m_row4->read(), m_row5->read(), m_row6->read(), m_row7->read() };
409
410   for (int i = 0; i < 8; i++)
411   {
412      if (!BIT(cia_pb, i))
413      {
414         if (!BIT(row[7], i)) data &= ~0x80;
415         if (!BIT(row[6], i)) data &= ~0x40;
416         if (!BIT(row[5], i)) data &= ~0x20;
417         if (!BIT(row[4], i)) data &= ~0x10;
418         if (!BIT(row[3], i)) data &= ~0x08;
419         if (!BIT(row[2], i)) data &= ~0x04;
420         if (!BIT(row[1], i)) data &= ~0x02;
421         if (!BIT(row[0], i)) data &= ~0x01;
422      }
423   }
424
425   return data;
298426}
299427
300428READ8_MEMBER( vic10_state::cia_pb_r )
r20545r20546
314442
315443   */
316444
317   UINT8 cia0porta = m_cia->pa_r();
445   UINT8 data = 0xff;
318446
319   return cbm_common_cia0_port_b_r(m_cia, cia0porta);
447   // joystick
448   UINT8 joy_a = m_joy1->joy_r();
449   
450   data &= (0xf0 | (joy_a & 0x0f));
451   data &= ~(!BIT(joy_a, 5) << 4);
452
453   // keyboard
454   UINT8 cia_pa = m_cia->pa_r();
455
456   if (!BIT(cia_pa, 7)) data &= m_row7->read();
457   if (!BIT(cia_pa, 6)) data &= m_row6->read();
458   if (!BIT(cia_pa, 5)) data &= m_row5->read();
459   if (!BIT(cia_pa, 4)) data &= m_row4->read();
460   if (!BIT(cia_pa, 3)) data &= m_row3->read();
461   if (!BIT(cia_pa, 2)) data &= m_row2->read();
462   if (!BIT(cia_pa, 1)) data &= m_row1->read() & m_lock->read();
463   if (!BIT(cia_pa, 0)) data &= m_row0->read();
464
465   return data;
320466}
321467
322468WRITE8_MEMBER( vic10_state::cia_pb_w )
r20545r20546
496642   MCFG_CPU_PROGRAM_MAP(vic10_mem)
497643   MCFG_M6510_PORT_CALLBACKS(READ8(vic10_state, cpu_r), WRITE8(vic10_state, cpu_w))
498644   MCFG_M6510_PORT_PULLS(0x10, 0x20)
499   MCFG_CPU_VBLANK_INT_DRIVER(SCREEN_TAG, vic10_state,  vic10_frame_interrupt)
500645   MCFG_QUANTUM_PERFECT_CPU(M6510_TAG)
501646
502647   // video hardware
r20545r20546
514659   MCFG_MOS6526_ADD(MOS6526_TAG, VIC6566_CLOCK, 60, cia_intf)
515660   MCFG_PET_DATASSETTE_PORT_ADD(PET_DATASSETTE_PORT_TAG, datassette_intf, cbm_datassette_devices, NULL, NULL)
516661   MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, NULL, NULL)
517   MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL, NULL)
662   MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, "joy", NULL)
518663   MCFG_VIC10_EXPANSION_SLOT_ADD(VIC10_EXPANSION_SLOT_TAG, VIC6566_CLOCK, expansion_intf, vic10_expansion_cards, NULL, NULL)
519664
520665   // software list
trunk/src/mess/includes/vic10.h
r20545r20546
33#ifndef __VIC10__
44#define __VIC10__
55
6
76#include "emu.h"
87#include "cpu/m6502/m6510.h"
9#include "includes/cbm.h"
108#include "machine/cbmipt.h"
119#include "machine/mos6526.h"
1210#include "machine/petcass.h"
r20545r20546
4038         m_ram(*this, RAM_TAG),
4139         m_cassette(*this, PET_DATASSETTE_PORT_TAG),
4240         m_color_ram(*this, "color_ram"),
41         m_row0(*this, "ROW0"),
42         m_row1(*this, "ROW1"),
43         m_row2(*this, "ROW2"),
44         m_row3(*this, "ROW3"),
45         m_row4(*this, "ROW4"),
46         m_row5(*this, "ROW5"),
47         m_row6(*this, "ROW6"),
48         m_row7(*this, "ROW7"),
49         m_restore(*this, "RESTORE"),
50         m_lock(*this, "LOCK"),
4351         m_cia_irq(CLEAR_LINE),
4452         m_vic_irq(CLEAR_LINE),
4553         m_exp_irq(CLEAR_LINE)
r20545r20546
5462   required_device<vic10_expansion_slot_device> m_exp;
5563   required_device<ram_device> m_ram;
5664   optional_device<pet_datassette_port_device> m_cassette;
65   optional_shared_ptr<UINT8> m_color_ram;
66   required_ioport m_row0;
67   required_ioport m_row1;
68   required_ioport m_row2;
69   required_ioport m_row3;
70   required_ioport m_row4;
71   required_ioport m_row5;
72   required_ioport m_row6;
73   required_ioport m_row7;
74   required_ioport m_restore;
75   required_ioport m_lock;
5776
5877   virtual void machine_start();
5978   virtual void machine_reset();
r20545r20546
85104
86105   DECLARE_WRITE_LINE_MEMBER( exp_irq_w );
87106
88   // video state
89   optional_shared_ptr<UINT8> m_color_ram;
90
91107   // interrupt state
92108   int m_cia_irq;
93109   int m_vic_irq;
94110   int m_exp_irq;
95   INTERRUPT_GEN_MEMBER(vic10_frame_interrupt);
96111};
97112
98113

Previous 199869 Revisions Next


© 1997-2024 The MAME Team