Previous 199869 Revisions Next

r26251 Monday 18th November, 2013 at 02:52:15 UTC by Jürgen Buchmüller
Add initial mouse support through PORT_CHANGED_MEMBER. Needs fixing, perhaps absolute position?
[/branches/alto2/src/emu/cpu/alto2]a2mouse.c alto2.h
[/branches/alto2/src/mess/drivers]alto2.c

branches/alto2/src/emu/cpu/alto2/a2mouse.c
r26250r26251
11#include "alto2.h"
22
3#define   MOUSE_DIRTY_HACK   0
4
35enum {
46   MX1      = (1<<0),      //!< MX1 signal is bit 0 (latch bit 1)
57   LMX1   = (1<<1),
r26250r26251
140142}
141143
142144/**
143 * @brief register a mouse motion
144 *
145 * @param x new mouse x coordinate
146 * @param y new mouse y coordinate
145 * @brief register a mouse motion in x direction
146 * @param ioport_field reference to the field
147 * @param param pointer passed in PORT_CHANGED_MEMBER last parameter
148 * @param oldval the old ioport_value
149 * @param newval the new ioport_value
147150 */
148void alto2_cpu_device::mouse_motion(int x, int y)
151INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_motion_x )
149152{
150   /* set new destination (absolute) mouse x and y coordinates */
151   m_mouse.dx = x;
152   m_mouse.dy = y;
153#if   1
153   // set new destination (absolute) mouse x coordinate
154   m_mouse.dx += newval - oldval;
155#if   MOUSE_DIRTY_HACK
154156   /* XXX: dirty, dirty, hack */
155157#if   ALTO2_HAMMING_CHECK
156   m_mem.ram[0424/2] = hamming_code(1, 0424 / 2, (x << 16) | y);
158   m_mem.ram[0424/2] = hamming_code(1, 0424 / 2, (m_mouse.dx << 16) | m_mouse.dy);
157159#else
158   m_mem.ram[0424/2] = (x << 16) | y;
160   m_mem.ram[0424/2] = (m_mouse.dx << 16) | m_mouse.dy;
159161#endif
160162#endif
161163}
162164
163165/**
166 * @brief register a mouse motion in y direction
167 * @param ioport_field reference to the field
168 * @param param pointer passed in PORT_CHANGED_MEMBER last parameter
169 * @param oldval the old ioport_value
170 * @param newval the new ioport_value
171 */
172INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_motion_y )
173{
174   // set new destination (absolute) mouse y coordinate
175   m_mouse.dy += newval - oldval;
176#if   MOUSE_DIRTY_HACK
177   /* XXX: dirty, dirty, hack */
178#if   ALTO2_HAMMING_CHECK
179   m_mem.ram[0424/2] = hamming_code(1, 0424 / 2, (m_mouse.dx << 16) | m_mouse.dy);
180#else
181   m_mem.ram[0424/2] = (m_mouse.dx << 16) | m_mouse.dy;
182#endif
183#endif
184}
185
186/**
164187 * @brief register a mouse button change
165188 *
166189 * convert button bits to UTILIN[13-15]
167190 *
168 * @param b mouse buttons (bit 0:left 1:right 2:middle)
191 * @param ioport_field reference to the field
192 * @param param pointer passed in PORT_CHANGED_MEMBER last parameter
193 * @param oldval the old ioport_value
194 * @param newval the new ioport_value
169195 */
170void alto2_cpu_device::mouse_button(int b)
196INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_buttons )
171197{
172   /* UTILIN[13] TOP or LEFT button (RED) */
173   PUT_MOUSE_RED   (m_hw.utilin, (b & (1 << 0)) ? 0 : 1);
174   /* UTILIN[14] BOTTOM or RIGHT button (BLUE) */
175   PUT_MOUSE_BLUE  (m_hw.utilin, (b & (1 << 1)) ? 0 : 1);
176   /* UTILIN[15] MIDDLE button (YELLOW) */
177   PUT_MOUSE_YELLOW(m_hw.utilin, (b & (1 << 2)) ? 0 : 1);
198   if (0x01 == (oldval ^ newval)) {
199      /* UTILIN[13] TOP or LEFT button (RED) */
200      PUT_MOUSE_RED   (m_hw.utilin, newval ? 0 : 1);
201   }
202   if (0x02 == (oldval ^ newval)) {
203      /* UTILIN[14] BOTTOM or RIGHT button (BLUE) */
204      PUT_MOUSE_BLUE  (m_hw.utilin, newval ? 0 : 1);
205   }
206   if (0x04 == (oldval ^ newval)) {
207      /* UTILIN[15] MIDDLE button (YELLOW) */
208      PUT_MOUSE_YELLOW(m_hw.utilin, newval ? 0 : 1);
209   }
178210}
179211
180212
branches/alto2/src/emu/cpu/alto2/alto2.h
r26250r26251
230230   DECLARE_ADDRESS_MAP( const_map, 16 );
231231   DECLARE_ADDRESS_MAP( iomem_map, 16 );
232232
233   //! register a mouse motion in x direction
234   DECLARE_INPUT_CHANGED_MEMBER( mouse_motion_x );
235   //! register a mouse motion in y direction
236   DECLARE_INPUT_CHANGED_MEMBER( mouse_motion_y );
237   //! register a mouse button change
238   DECLARE_INPUT_CHANGED_MEMBER( mouse_buttons );
239
233240protected:
234241   //! device-level override for start
235242   virtual void device_start();
r26250r26251
13881395   }   m_mouse;
13891396
13901397   UINT16 mouse_read();                     //!< return the mouse motion flags
1391   void mouse_motion(int x, int y);            //!< register a mouse motion
1392   void mouse_button(int b);                  //!< register a mouse button change
13931398   void init_mouse();                        //!< initialize the mouse context to useful values
13941399   void exit_mouse();                        //!< deinitialize the mouse
13951400
branches/alto2/src/mess/drivers/alto2.c
r26250r26251
2121
2222void alto2_state::screen_eof_alto2(screen_device &screen, bool state)
2323{
24   // FIXME: what do we do here?
24   // TODO: anything?
2525}
2626
2727/* Input Ports */
r26250r26251
205205   PORT_BIT(A2_KEY_FL4,      IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("FL4") PORT_CODE(KEYCODE_F4)                           //!< ADL left function key 4
206206   PORT_BIT(A2_KEY_FR5,      IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("FR5") PORT_CODE(KEYCODE_F9)                           //!< ADL right function key 5
207207
208   PORT_START("CONFIG")    /* config diode on main board */
208   PORT_START("mouseb")   // Mouse buttons
209   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse RED (left)")      PORT_CODE(MOUSECODE_BUTTON1) PORT_CHANGED_MEMBER( ":maincpu", alto2_cpu_device, mouse_buttons, 0 )
210   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse BLUE (right)")    PORT_CODE(MOUSECODE_BUTTON2) PORT_CHANGED_MEMBER( ":maincpu", alto2_cpu_device, mouse_buttons, 0 )
211   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Mouse YELLOW (middel)") PORT_CODE(MOUSECODE_BUTTON3) PORT_CHANGED_MEMBER( ":maincpu", alto2_cpu_device, mouse_buttons, 0 )
212
213   PORT_START("mousex")   // Mouse - X AXIS
214   PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_CHANGED_MEMBER( ":maincpu", alto2_cpu_device, mouse_motion_x, 0 )
215
216   PORT_START("mousey")   // Mouse - Y AXIS
217   PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_CHANGED_MEMBER( ":maincpu", alto2_cpu_device, mouse_motion_y, 0 )
218
219PORT_START("CONFIG")    /* config diode on main board */
209220   PORT_CONFNAME( 0x40, 0x40, "TV system")
210221   PORT_CONFSETTING(    0x00, "NTSC")
211222   PORT_CONFSETTING(    0x40, "PAL")

Previous 199869 Revisions Next


© 1997-2024 The MAME Team