Previous 199869 Revisions Next

r20498 Saturday 26th January, 2013 at 18:53:13 UTC by Curt Coder
(MESS) c64/c128: Implemented parallel joystick pot X/Y read. [Curt Coder]
(MESS) vcsctrl: Removed runtime tag lookups. (nw)
[src/mess/drivers]c128.c c64.c
[src/mess/machine]c64_multiscreen.c vcs_joy.c vcs_joy.h vcs_joybooster.c vcs_joybooster.h vcs_keypad.c vcs_keypad.h vcs_lightpen.c vcs_lightpen.h vcs_paddles.c vcs_paddles.h vcs_wheel.c vcs_wheel.h vcsctrl.c vcsctrl.h

trunk/src/mess/machine/vcs_wheel.c
r20497r20498
4949
5050vcs_wheel_device::vcs_wheel_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
5151   device_t(mconfig, VCS_WHEEL, "Driving Wheel", tag, owner, clock),
52   device_vcs_control_port_interface(mconfig, *this)
52   device_vcs_control_port_interface(mconfig, *this),
53   m_joy(*this, "JOY"),
54   m_wheel(*this, "WHEEL")
5355{
5456}
5557
r20497r20498
7173{
7274   static const UINT8 driving_lookup[4] = { 0x00, 0x02, 0x03, 0x01 };
7375
74   return ioport("JOY")->read() | driving_lookup[ ( ioport("WHEEL")->read() & 0x18 ) >> 3 ];
76   return m_joy->read() | driving_lookup[ ( m_wheel->read() & 0x18 ) >> 3 ];
7577}
trunk/src/mess/machine/vcs_wheel.h
r20497r20498
4141
4242   // device_vcs_control_port_interface overrides
4343   virtual UINT8 vcs_joy_r();
44
45private:
46   required_ioport m_joy;
47   required_ioport m_wheel;
4448};
4549
4650
trunk/src/mess/machine/vcs_lightpen.c
r20497r20498
5858
5959vcs_lightpen_device::vcs_lightpen_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
6060   device_t(mconfig, VCS_LIGHTPEN, "Light Pen", tag, owner, clock),
61   device_vcs_control_port_interface(mconfig, *this)
61   device_vcs_control_port_interface(mconfig, *this),
62   m_joy(*this, "JOY"),
63   m_lightx(*this, "LIGHTX"),
64   m_lighty(*this, "LIGHTY")
6265{
6366}
6467
r20497r20498
7881
7982UINT8 vcs_lightpen_device::vcs_joy_r()
8083{
81   return ioport("JOY")->read();
84   return m_joy->read();
8285}
trunk/src/mess/machine/vcs_lightpen.h
r20497r20498
4343
4444   // device_vcs_control_port_interface overrides
4545   virtual UINT8 vcs_joy_r();
46
47private:
48   required_ioport m_joy;
49   required_ioport m_lightx;
50   required_ioport m_lighty;
4651};
4752
4853
trunk/src/mess/machine/vcs_joybooster.c
r20497r20498
5959
6060vcs_joystick_booster_device::vcs_joystick_booster_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
6161   device_t(mconfig, VCS_JOYSTICK_BOOSTER, "Digital joystick with Boostergrip", tag, owner, clock),
62   device_vcs_control_port_interface(mconfig, *this)
62   device_vcs_control_port_interface(mconfig, *this),
63   m_joy(*this, "JOY"),
64   m_potx(*this, "POTX"),
65   m_poty(*this, "POTY")
6366{
6467}
6568
r20497r20498
7982
8083UINT8 vcs_joystick_booster_device::vcs_joy_r()
8184{
82   return ioport("JOY")->read();
85   return m_joy->read();
8386}
8487
8588UINT8 vcs_joystick_booster_device::vcs_pot_x_r()
8689{
87   return ioport("POTX")->read();
90   return m_potx->read();
8891}
8992
9093UINT8 vcs_joystick_booster_device::vcs_pot_y_r()
9194{
92   return ioport("POTY")->read();
95   return m_poty->read();
9396}
trunk/src/mess/machine/vcs_joybooster.h
r20497r20498
4444   virtual UINT8 vcs_joy_r();
4545   virtual UINT8 vcs_pot_x_r();
4646   virtual UINT8 vcs_pot_y_r();
47
48   virtual bool has_pot_x() { return true; }
49   virtual bool has_pot_y() { return true; }
50   
51private:
52   required_ioport m_joy;
53   required_ioport m_potx;
54   required_ioport m_poty;
4755};
4856
4957
trunk/src/mess/machine/vcs_keypad.c
r20497r20498
5656
5757vcs_keypad_device::vcs_keypad_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
5858   device_t(mconfig, VCS_KEYPAD, "Keypad", tag, owner, clock),
59   device_vcs_control_port_interface(mconfig, *this)
59   device_vcs_control_port_interface(mconfig, *this),
60   m_keypad(*this, "KEYPAD")
6061{
6162}
6263
r20497r20498
8283   {
8384      if ( ! ( ( m_column >> i ) & 0x01 ) )
8485      {
85         if ( ( ioport("KEYPAD")->read() >> 3*i ) & 0x04 )
86         if ( ( m_keypad->read() >> 3*i ) & 0x04 )
8687         {
8788            return 0xff;
8889         }
r20497r20498
106107   {
107108      if ( ! ( ( m_column >> i ) & 0x01 ) )
108109      {
109         if ( ( ioport("KEYPAD")->read() >> 3*i ) & 0x01 )
110         if ( ( m_keypad->read() >> 3*i ) & 0x01 )
110111         {
111112            return 0;
112113         }
r20497r20498
125126   {
126127      if ( ! ( ( m_column >> i ) & 0x01 ) )
127128      {
128         if ( ( ioport("KEYPAD")->read() >> 3*i ) & 0x02 )
129         if ( ( m_keypad->read() >> 3*i ) & 0x02 )
129130         {
130131            return 0;
131132         }
trunk/src/mess/machine/vcs_keypad.h
r20497r20498
2525// ======================> vcs_keypad_device
2626
2727class vcs_keypad_device : public device_t,
28                     public device_vcs_control_port_interface
28                    public device_vcs_control_port_interface
2929{
3030public:
3131   // construction/destruction
r20497r20498
4545   virtual UINT8 vcs_pot_x_r();
4646   virtual UINT8 vcs_pot_y_r();
4747
48   virtual bool has_pot_x() { return true; }
49   virtual bool has_pot_y() { return true; }
50
51private:
52   required_ioport m_keypad;
53
4854   UINT8   m_column;
4955};
5056
trunk/src/mess/machine/vcs_joy.c
r20497r20498
5050
5151vcs_joystick_device::vcs_joystick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
5252   device_t(mconfig, VCS_JOYSTICK, "Digital joystick", tag, owner, clock),
53   device_vcs_control_port_interface(mconfig, *this)
53   device_vcs_control_port_interface(mconfig, *this),
54   m_joy(*this, "JOY")
5455{
5556}
5657
r20497r20498
7071
7172UINT8 vcs_joystick_device::vcs_joy_r()
7273{
73   return ioport("JOY")->read();
74   return m_joy->read();
7475}
trunk/src/mess/machine/vcs_joy.h
r20497r20498
4141
4242   // device_vcs_control_port_interface overrides
4343   virtual UINT8 vcs_joy_r();
44
45private:
46   required_ioport m_joy;
4447};
4548
4649
trunk/src/mess/machine/c64_multiscreen.c
r20497r20498
4848    TODO:
4949
5050    - M6802 board
51    - crashes on boot
5152
53        805A: lda  $01
54        805C: and  #$FE
55        805E: sta  $01
56        8060: m6502_brk#$00 <-- BOOM!
57
5258*/
5359
5460#include "c64_multiscreen.h"
trunk/src/mess/machine/vcs_paddles.c
r20497r20498
5353
5454vcs_paddles_device::vcs_paddles_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
5555   device_t(mconfig, VCS_PADDLES, "Digital paddles", tag, owner, clock),
56   device_vcs_control_port_interface(mconfig, *this)
56   device_vcs_control_port_interface(mconfig, *this),
57   m_joy(*this, "JOY"),
58   m_potx(*this, "POTX"),
59   m_poty(*this, "POTY")
5760{
5861}
5962
r20497r20498
7376
7477UINT8 vcs_paddles_device::vcs_joy_r()
7578{
76   return ioport("JOY")->read();
79   return m_joy->read();
7780}
7881
7982
r20497r20498
8386
8487UINT8 vcs_paddles_device::vcs_pot_x_r()
8588{
86   return ioport("POTX")->read();
89   return m_potx->read();
8790}
8891
8992
r20497r20498
9396
9497UINT8 vcs_paddles_device::vcs_pot_y_r()
9598{
96   return ioport("POTY")->read();
99   return m_poty->read();
97100}
trunk/src/mess/machine/vcs_paddles.h
r20497r20498
4343   virtual UINT8 vcs_joy_r();
4444   virtual UINT8 vcs_pot_x_r();
4545   virtual UINT8 vcs_pot_y_r();
46
47   virtual bool has_pot_x() { return true; }
48   virtual bool has_pot_y() { return true; }
49
50private:
51   required_ioport m_joy;
52   required_ioport m_potx;
53   required_ioport m_poty;
4654};
4755
4856
trunk/src/mess/machine/vcsctrl.c
r20497r20498
5353//-------------------------------------------------
5454
5555vcs_control_port_device::vcs_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
56      device_t(mconfig, VCS_CONTROL_PORT, "Atari VCS control port", tag, owner, clock),
57      device_slot_interface(mconfig, *this)
56   device_t(mconfig, VCS_CONTROL_PORT, "Atari VCS control port", tag, owner, clock),
57   device_slot_interface(mconfig, *this)
5858{
5959}
6060
r20497r20498
7878}
7979
8080
81UINT8 vcs_control_port_device::joy_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_joy_r(); return data; }
81UINT8 vcs_control_port_device::joy_r() { UINT8 data = 0xff; if (exists()) data = m_device->vcs_joy_r(); return data; }
8282READ8_MEMBER( vcs_control_port_device::joy_r ) { return joy_r(); }
83UINT8 vcs_control_port_device::pot_x_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_pot_x_r(); return data; }
83UINT8 vcs_control_port_device::pot_x_r() { UINT8 data = 0xff; if (exists()) data = m_device->vcs_pot_x_r(); return data; }
8484READ8_MEMBER( vcs_control_port_device::pot_x_r ) { return pot_x_r(); }
85UINT8 vcs_control_port_device::pot_y_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_pot_y_r(); return data; }
85UINT8 vcs_control_port_device::pot_y_r() { UINT8 data = 0xff; if (exists()) data = m_device->vcs_pot_y_r(); return data; }
8686READ8_MEMBER( vcs_control_port_device::pot_y_r ) { return pot_y_r(); }
87void vcs_control_port_device::joy_w( UINT8 data ) { if ( m_device != NULL ) m_device->vcs_joy_w( data ); }
87void vcs_control_port_device::joy_w( UINT8 data ) { if ( exists() ) m_device->vcs_joy_w( data ); }
8888WRITE8_MEMBER( vcs_control_port_device::joy_w ) { joy_w(data); }
89bool vcs_control_port_device::exists() { return m_device != NULL; }
90bool vcs_control_port_device::has_pot_x() { return exists() && m_device->has_pot_x(); }
91bool vcs_control_port_device::has_pot_y() { return exists() && m_device->has_pot_y(); }
8992
90
9193//-------------------------------------------------
9294//  SLOT_INTERFACE( vcs_control_port_devices )
9395//-------------------------------------------------
trunk/src/mess/machine/vcsctrl.h
r20497r20498
6868   void joy_w( UINT8 data );
6969   DECLARE_WRITE8_MEMBER( joy_w );
7070
71   bool exists();
72   bool has_pot_x();
73   bool has_pot_y();
74
7175protected:
7276   // device-level overrides
7377   virtual void device_start();
r20497r20498
9195   virtual UINT8 vcs_pot_y_r() { return 0xff; };
9296   virtual void vcs_joy_w(UINT8 data) { };
9397
98   virtual bool has_pot_x() { return false; }
99   virtual bool has_pot_y() { return false; }
100
94101protected:
95102   vcs_control_port_device *m_port;
96103};
trunk/src/mess/drivers/c64.c
r20497r20498
88        - IRQ (WRONG $DC0D)
99        - NMI (WRONG $DD0D)
1010        - some CIA tests
11
1211    - 64C PLA dump
13    - Multiscreen crashes on boot
1412
15        805A: lda  $01
16        805C: and  #$FE
17        805E: sta  $01
18        8060: m6502_brk#$00 <-- BOOM!
19
2013*/
2114
2215#include "includes/c64.h"
r20497r20498
512505   {
513506   case 1: data = m_joy1->pot_x_r(); break;
514507   case 2: data = m_joy2->pot_x_r(); break;
515   case 3: break; // TODO pot1 and pot2 in series
508   case 3:
509      if (m_joy1->has_pot_x() && m_joy2->has_pot_x())
510      {
511         data = 1 / (1 / m_joy1->pot_x_r() + 1 / m_joy2->pot_x_r());
512      }
513      else if (m_joy1->has_pot_x())
514      {
515         data = m_joy1->pot_x_r();
516      }
517      else if (m_joy2->has_pot_x())
518      {
519         data = m_joy2->pot_x_r();
520      }
521      break;
516522   }
517523
518524   return data;
r20497r20498
526532   {
527533   case 1: data = m_joy1->pot_y_r(); break;
528534   case 2: data = m_joy2->pot_y_r(); break;
529   case 3: break; // TODO pot1 and pot2 in series
535   case 3:
536      if (m_joy1->has_pot_y() && m_joy2->has_pot_y())
537      {
538         data = 1 / (1 / m_joy1->pot_y_r() + 1 / m_joy2->pot_y_r());
539      }
540      else if (m_joy1->has_pot_y())
541      {
542         data = m_joy1->pot_y_r();
543      }
544      else if (m_joy2->has_pot_y())
545      {
546         data = m_joy2->pot_y_r();
547      }
548      break;
530549   }
531550
532551   return data;
trunk/src/mess/drivers/c128.c
r20497r20498
927927   {
928928   case 1: data = m_joy1->pot_x_r(); break;
929929   case 2: data = m_joy2->pot_x_r(); break;
930   case 3: break; // TODO pot1 and pot2 in series
930   case 3:
931      if (m_joy1->has_pot_x() && m_joy2->has_pot_x())
932      {
933         data = 1 / (1 / m_joy1->pot_x_r() + 1 / m_joy2->pot_x_r());
934      }
935      else if (m_joy1->has_pot_x())
936      {
937         data = m_joy1->pot_x_r();
938      }
939      else if (m_joy2->has_pot_x())
940      {
941         data = m_joy2->pot_x_r();
942      }
943      break;
931944   }
932945
933946   return data;
r20497r20498
941954   {
942955   case 1: data = m_joy1->pot_y_r(); break;
943956   case 2: data = m_joy2->pot_y_r(); break;
944   case 3: break; // TODO pot1 and pot2 in series
957   case 3:
958      if (m_joy1->has_pot_y() && m_joy2->has_pot_y())
959      {
960         data = 1 / (1 / m_joy1->pot_y_r() + 1 / m_joy2->pot_y_r());
961      }
962      else if (m_joy1->has_pot_y())
963      {
964         data = m_joy1->pot_y_r();
965      }
966      else if (m_joy2->has_pot_y())
967      {
968         data = m_joy2->pot_y_r();
969      }
970      break;
945971   }
946972
947973   return data;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team