branches/alto2/src/emu/cpu/alto2/a2mouse.c
| r26250 | r26251 | |
| 1 | 1 | #include "alto2.h" |
| 2 | 2 | |
| 3 | #define MOUSE_DIRTY_HACK 0 |
| 4 | |
| 3 | 5 | enum { |
| 4 | 6 | MX1 = (1<<0), //!< MX1 signal is bit 0 (latch bit 1) |
| 5 | 7 | LMX1 = (1<<1), |
| r26250 | r26251 | |
| 140 | 142 | } |
| 141 | 143 | |
| 142 | 144 | /** |
| 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 |
| 147 | 150 | */ |
| 148 | | void alto2_cpu_device::mouse_motion(int x, int y) |
| 151 | INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_motion_x ) |
| 149 | 152 | { |
| 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 |
| 154 | 156 | /* XXX: dirty, dirty, hack */ |
| 155 | 157 | #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); |
| 157 | 159 | #else |
| 158 | | m_mem.ram[0424/2] = (x << 16) | y; |
| 160 | m_mem.ram[0424/2] = (m_mouse.dx << 16) | m_mouse.dy; |
| 159 | 161 | #endif |
| 160 | 162 | #endif |
| 161 | 163 | } |
| 162 | 164 | |
| 163 | 165 | /** |
| 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 | */ |
| 172 | INPUT_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 | /** |
| 164 | 187 | * @brief register a mouse button change |
| 165 | 188 | * |
| 166 | 189 | * convert button bits to UTILIN[13-15] |
| 167 | 190 | * |
| 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 |
| 169 | 195 | */ |
| 170 | | void alto2_cpu_device::mouse_button(int b) |
| 196 | INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_buttons ) |
| 171 | 197 | { |
| 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 | } |
| 178 | 210 | } |
| 179 | 211 | |
| 180 | 212 | |
branches/alto2/src/emu/cpu/alto2/alto2.h
| r26250 | r26251 | |
| 230 | 230 | DECLARE_ADDRESS_MAP( const_map, 16 ); |
| 231 | 231 | DECLARE_ADDRESS_MAP( iomem_map, 16 ); |
| 232 | 232 | |
| 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 | |
| 233 | 240 | protected: |
| 234 | 241 | //! device-level override for start |
| 235 | 242 | virtual void device_start(); |
| r26250 | r26251 | |
| 1388 | 1395 | } m_mouse; |
| 1389 | 1396 | |
| 1390 | 1397 | 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 |
| 1393 | 1398 | void init_mouse(); //!< initialize the mouse context to useful values |
| 1394 | 1399 | void exit_mouse(); //!< deinitialize the mouse |
| 1395 | 1400 | |
branches/alto2/src/mess/drivers/alto2.c
| r26250 | r26251 | |
| 21 | 21 | |
| 22 | 22 | void alto2_state::screen_eof_alto2(screen_device &screen, bool state) |
| 23 | 23 | { |
| 24 | | // FIXME: what do we do here? |
| 24 | // TODO: anything? |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /* Input Ports */ |
| r26250 | r26251 | |
| 205 | 205 | PORT_BIT(A2_KEY_FL4, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("FL4") PORT_CODE(KEYCODE_F4) //!< ADL left function key 4 |
| 206 | 206 | PORT_BIT(A2_KEY_FR5, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("FR5") PORT_CODE(KEYCODE_F9) //!< ADL right function key 5 |
| 207 | 207 | |
| 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 | |
| 219 | PORT_START("CONFIG") /* config diode on main board */ |
| 209 | 220 | PORT_CONFNAME( 0x40, 0x40, "TV system") |
| 210 | 221 | PORT_CONFSETTING( 0x00, "NTSC") |
| 211 | 222 | PORT_CONFSETTING( 0x40, "PAL") |