Previous 199869 Revisions Next

r32539 Saturday 4th October, 2014 at 21:59:32 UTC by Wilbert Pol
(MESS) sms.c: Added support for Sega Graphic Board input. (nw)
[src/emu/bus/sms_ctrl]graphic.c* graphic.h* smsctrl.c

trunk/src/emu/bus/sms_ctrl/graphic.h
r0r32539
1/**********************************************************************
2
3    Sega Master System "Graphic Board" emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __SMS_GRAPHIC__
13#define __SMS_GRAPHIC__
14
15
16#include "emu.h"
17#include "smsctrl.h"
18
19
20
21//**************************************************************************
22//  TYPE DEFINITIONS
23//**************************************************************************
24
25// ======================> sms_graphic_device
26
27class sms_graphic_device : public device_t,
28                     public device_sms_control_port_interface
29{
30public:
31   // construction/destruction
32   sms_graphic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
33
34   // optional information overrides
35   virtual ioport_constructor device_input_ports() const;
36
37protected:
38   // device-level overrides
39   virtual void device_start();
40
41   // device_sms_control_port_interface overrides
42   virtual UINT8 peripheral_r();
43   virtual void peripheral_w(UINT8 data);
44
45private:
46   required_ioport m_buttons;
47   required_ioport m_x;
48   required_ioport m_y;
49
50   int m_index;
51   UINT8 m_previous_write;
52   UINT8 m_pressure;
53};
54
55
56// device type definition
57extern const device_type SMS_GRAPHIC;
58
59
60#endif
Property changes on: trunk/src/emu/bus/sms_ctrl/graphic.h
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
trunk/src/emu/bus/sms_ctrl/smsctrl.c
r32538r32539
1616#include "sportsjp.h"
1717#include "rfu.h"
1818#include "multitap.h"
19#include "graphic.h"
1920
2021
2122
r32538r32539
129130   SLOT_INTERFACE("sportspadjp", SMS_SPORTS_PAD_JP)
130131   SLOT_INTERFACE("rapidfire", SMS_RAPID_FIRE)
131132   SLOT_INTERFACE("multitap", SMS_MULTITAP)
133   SLOT_INTERFACE("graphic", SMS_GRAPHIC)
132134SLOT_INTERFACE_END
trunk/src/emu/bus/sms_ctrl/graphic.c
r0r32539
1/**********************************************************************
2
3    Sega Master System "Graphic Board" emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8I/O 3f write | this method
9        0x20 | 0x7f
10        0x00 | 0x3f
11        0x30 | 0xff
12   
13Typical sequence:
14- 3f write 0x20
15- read dc
16- 3f write 0x00
17- read dc   
18- 3f write 0x20
19- read dc
20- 3f write 0x30
21Suspect from kind of counter that is reset by a 0x30 write to I/O port 0x3f.
22Once reset reads from i/O port dc expect to see 0xE0.
23And then any write with differing bits goes through several internal I/O ports
24with the first port being the one with the buttons
25
26In the reset/start state the lower four/five bits are 0.
27Then a nibble is read containing the buttons (active low)
28Then 2 nibbles are read to form a byte (first high nibble, then low nibble) indicating
29whether the pen is on the graphic board, a value of FD, FE, or FF used for this. For
30any other value the following 2 bytes are not read.
31Then 2 nibbles are read to form a byte containing the absolute X coordinate.
32THen 2 nibbles are read to form a byte containing the absolute Y coordiante.
33
34**********************************************************************/
35
36#include "graphic.h"
37
38
39
40//**************************************************************************
41//  DEVICE DEFINITIONS
42//**************************************************************************
43
44const device_type SMS_GRAPHIC = &device_creator<sms_graphic_device>;
45
46
47static INPUT_PORTS_START( sms_graphic )
48    PORT_START("BUTTONS")
49    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) // MENU
50    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) // DO
51    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) // PEN
52    PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNUSED )
53
54   PORT_START("X")
55   PORT_BIT( 0xff, 0x00, IPT_LIGHTGUN_X) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(15)
56
57   PORT_START("Y")
58   PORT_BIT( 0xff, 0x00, IPT_LIGHTGUN_Y) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(15)
59INPUT_PORTS_END
60
61
62//-------------------------------------------------
63//  input_ports - device-specific input ports
64//-------------------------------------------------
65
66ioport_constructor sms_graphic_device::device_input_ports() const
67{
68   return INPUT_PORTS_NAME( sms_graphic );
69}
70
71//**************************************************************************
72//  LIVE DEVICE
73//**************************************************************************
74
75//-------------------------------------------------
76//  sms_graphic_device - constructor
77//-------------------------------------------------
78
79sms_graphic_device::sms_graphic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
80   : device_t(mconfig, SMS_GRAPHIC, "Graphic Board", tag, owner, clock, "sms_joypad", __FILE__)
81   , device_sms_control_port_interface(mconfig, *this)
82   , m_buttons(*this, "BUTTONS")
83   , m_x(*this, "X")
84   , m_y(*this, "Y")
85   , m_index(0)
86   , m_previous_write(0xff)
87   , m_pressure(0xfd)
88{
89}
90
91
92//-------------------------------------------------
93//  device_start - device-specific startup
94//-------------------------------------------------
95
96void sms_graphic_device::device_start()
97{
98   save_item(NAME(m_index));
99   save_item(NAME(m_previous_write));
100}
101
102
103//-------------------------------------------------
104//  sms_peripheral_r - joypad read
105//-------------------------------------------------
106
107UINT8 sms_graphic_device::peripheral_r()
108{
109   switch (m_index)
110   {
111      case 0:     // Initial state / "I am a board"
112         // If any regular button is pressed raise/lower TL ?
113//         if ((m_buttons->read() & 0x07) != 0x07)
114//            return 0xf0;
115         return 0xd0;
116
117      case 1:    // Read buttons (active low)
118         return m_buttons->read();
119
120      case 2:    // Some thing only FD, FE, and FF cause the other values to be read
121         return m_pressure >> 4;
122
123      case 3:
124         return m_pressure & 0x0f;
125
126      case 4:    // High nibble X?
127         return m_x->read() >> 4;
128
129      case 5:    // Low nibble X?
130         return m_x->read() & 0x0f;
131
132      case 6:   // High nibble Y?
133         return m_y->read() >> 4;
134
135      case 7:   // Low Nibble Y?
136         return m_y->read() & 0x0f;
137   }
138
139   return 0xff;
140}
141
142void sms_graphic_device::peripheral_w(UINT8 data)
143{
144   // Check for toggle on TH/TL
145   if ((data ^ m_previous_write) & 0xc0)
146   {
147      m_index++;
148   }
149
150   // If TR is high, restart
151   if (data & 0x80)
152   {
153      m_index = 0;
154   }
155
156   m_previous_write = data;
157}
158
Property changes on: trunk/src/emu/bus/sms_ctrl/graphic.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Previous 199869 Revisions Next


© 1997-2024 The MAME Team