trunk/src/emu/bus/ql/sandy_superqboard.c
| r30842 | r30843 | |
| 2 | 2 | // copyright-holders:Curt Coder, Phill Harvey-Smith |
| 3 | 3 | /********************************************************************** |
| 4 | 4 | |
| 5 | | Sandy SuperQBoard (with HD upgrade) emulation |
| 5 | Sandy SuperQBoard/SuperQMouse (with HD upgrade) emulation |
| 6 | 6 | |
| 7 | 7 | Copyright MESS Team. |
| 8 | 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | 9 | |
| 10 | 10 | **********************************************************************/ |
| 11 | 11 | |
| 12 | | /* |
| 13 | | |
| 14 | | TODO: |
| 15 | | |
| 16 | | - mouse |
| 17 | | |
| 18 | | */ |
| 19 | | |
| 20 | 12 | #include "sandy_superqboard.h" |
| 21 | 13 | |
| 22 | 14 | |
| r30842 | r30843 | |
| 37 | 29 | |
| 38 | 30 | const device_type SANDY_SUPERQBOARD = &device_creator<sandy_superqboard_t>; |
| 39 | 31 | const device_type SANDY_SUPERQBOARD_512K = &device_creator<sandy_superqboard_512k_t>; |
| 32 | const device_type SANDY_SUPERQMOUSE = &device_creator<sandy_superqmouse_t>; |
| 33 | const device_type SANDY_SUPERQMOUSE_512K = &device_creator<sandy_superqmouse_512k_t>; |
| 40 | 34 | |
| 41 | 35 | |
| 42 | 36 | //------------------------------------------------- |
| r30842 | r30843 | |
| 93 | 87 | |
| 94 | 88 | WRITE_LINE_MEMBER( sandy_superqboard_t::busy_w ) |
| 95 | 89 | { |
| 96 | | m_busy = state; |
| 90 | if (state) |
| 91 | { |
| 92 | m_status |= ST_BUSY; |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | m_status &= ~ST_BUSY; |
| 97 | } |
| 98 | |
| 97 | 99 | check_interrupt(); |
| 98 | 100 | } |
| 99 | 101 | |
| r30842 | r30843 | |
| 124 | 126 | } |
| 125 | 127 | |
| 126 | 128 | |
| 129 | //------------------------------------------------- |
| 130 | // INPUT_CHANGED_MEMBER( mouse_x_changed ) |
| 131 | //------------------------------------------------- |
| 127 | 132 | |
| 133 | INPUT_CHANGED_MEMBER( sandy_superqboard_t::mouse_x_changed ) |
| 134 | { |
| 135 | if (newval > oldval) |
| 136 | { |
| 137 | m_status |= ST_X_DIR; |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | m_status &= ~ST_X_DIR; |
| 142 | } |
| 143 | |
| 144 | m_status |= ST_X_INT; |
| 145 | |
| 146 | check_interrupt(); |
| 147 | } |
| 148 | |
| 149 | |
| 150 | //------------------------------------------------- |
| 151 | // INPUT_CHANGED_MEMBER( mouse_y_changed ) |
| 152 | //------------------------------------------------- |
| 153 | |
| 154 | INPUT_CHANGED_MEMBER( sandy_superqboard_t::mouse_y_changed ) |
| 155 | { |
| 156 | if (newval < oldval) |
| 157 | { |
| 158 | m_status |= ST_Y_DIR; |
| 159 | } |
| 160 | else |
| 161 | { |
| 162 | m_status &= ~ST_Y_DIR; |
| 163 | } |
| 164 | |
| 165 | m_status |= ST_Y_INT; |
| 166 | |
| 167 | check_interrupt(); |
| 168 | } |
| 169 | |
| 170 | |
| 171 | //------------------------------------------------- |
| 172 | // INPUT_PORTS( sandy_superqmouse ) |
| 173 | //------------------------------------------------- |
| 174 | |
| 175 | INPUT_PORTS_START( sandy_superqmouse ) |
| 176 | PORT_START("mouse_x") |
| 177 | PORT_BIT( 0xff, 0x00, IPT_MOUSE_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(5) PORT_MINMAX(0, 255) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, sandy_superqmouse_t, mouse_x_changed, 0) |
| 178 | |
| 179 | PORT_START("mouse_y") |
| 180 | PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(5) PORT_MINMAX(0, 255) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, sandy_superqmouse_t, mouse_y_changed, 0) |
| 181 | |
| 182 | PORT_START("mouse_buttons") |
| 183 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Middle Mouse Button") PORT_CODE(MOUSECODE_BUTTON3) |
| 184 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Right Mouse Button") PORT_CODE(MOUSECODE_BUTTON2) |
| 185 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Left Mouse Button") PORT_CODE(MOUSECODE_BUTTON1) |
| 186 | INPUT_PORTS_END |
| 187 | |
| 188 | |
| 189 | //------------------------------------------------- |
| 190 | // input_ports - device-specific input ports |
| 191 | //------------------------------------------------- |
| 192 | |
| 193 | ioport_constructor sandy_superqmouse_t::device_input_ports() const |
| 194 | { |
| 195 | return INPUT_PORTS_NAME( sandy_superqmouse ); |
| 196 | } |
| 197 | |
| 198 | |
| 199 | //------------------------------------------------- |
| 200 | // input_ports - device-specific input ports |
| 201 | //------------------------------------------------- |
| 202 | |
| 203 | ioport_constructor sandy_superqmouse_512k_t::device_input_ports() const |
| 204 | { |
| 205 | return INPUT_PORTS_NAME( sandy_superqmouse ); |
| 206 | } |
| 207 | |
| 208 | |
| 209 | |
| 128 | 210 | //************************************************************************** |
| 129 | 211 | // LIVE DEVICE |
| 130 | 212 | //************************************************************************** |
| r30842 | r30843 | |
| 143 | 225 | m_latch(*this, TTL74273_TAG), |
| 144 | 226 | m_rom(*this, "rom"), |
| 145 | 227 | m_ram(*this, "ram"), |
| 228 | m_buttons(*this, "mouse_buttons"), |
| 146 | 229 | m_ram_size(256*1024), |
| 147 | | m_busy(1), |
| 148 | | m_int2(0), |
| 149 | | m_int3(0), |
| 150 | 230 | m_fd6(0), |
| 151 | | m_fd7(0) |
| 231 | m_fd7(0), |
| 232 | m_status(0) |
| 152 | 233 | { |
| 153 | 234 | } |
| 154 | 235 | |
| r30842 | r30843 | |
| 162 | 243 | m_latch(*this, TTL74273_TAG), |
| 163 | 244 | m_rom(*this, "rom"), |
| 164 | 245 | m_ram(*this, "ram"), |
| 246 | m_buttons(*this, "mouse_buttons"), |
| 165 | 247 | m_ram_size(ram_size), |
| 166 | | m_busy(1), |
| 167 | | m_int2(0), |
| 168 | | m_int3(0), |
| 169 | 248 | m_fd6(0), |
| 170 | | m_fd7(0) |
| 249 | m_fd7(0), |
| 250 | m_status(0) |
| 171 | 251 | { |
| 172 | 252 | } |
| 173 | 253 | |
| 174 | 254 | sandy_superqboard_512k_t::sandy_superqboard_512k_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 175 | 255 | : sandy_superqboard_t(mconfig, SANDY_SUPERQBOARD_512K, "Sandy SuperQBoard 512K", tag, owner, clock, "ql_sqboard", __FILE__, 512*1024) { } |
| 176 | 256 | |
| 257 | sandy_superqmouse_t::sandy_superqmouse_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 258 | : sandy_superqboard_t(mconfig, SANDY_SUPERQMOUSE, "Sandy SuperQMouse", tag, owner, clock, "ql_sqboard", __FILE__, 256*1024) { } |
| 177 | 259 | |
| 260 | sandy_superqmouse_512k_t::sandy_superqmouse_512k_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 261 | : sandy_superqboard_t(mconfig, SANDY_SUPERQMOUSE_512K, "Sandy SuperQMouse 512K", tag, owner, clock, "ql_sqboard", __FILE__, 512*1024) { } |
| 262 | |
| 263 | |
| 178 | 264 | //------------------------------------------------- |
| 179 | 265 | // device_start - device-specific startup |
| 180 | 266 | //------------------------------------------------- |
| r30842 | r30843 | |
| 185 | 271 | m_ram.allocate(m_ram_size); |
| 186 | 272 | |
| 187 | 273 | // state saving |
| 188 | | save_item(NAME(m_busy)); |
| 189 | | save_item(NAME(m_int2)); |
| 190 | | save_item(NAME(m_int3)); |
| 191 | 274 | save_item(NAME(m_fd6)); |
| 192 | 275 | save_item(NAME(m_fd7)); |
| 276 | save_item(NAME(m_status)); |
| 193 | 277 | } |
| 194 | 278 | |
| 195 | 279 | |
| r30842 | r30843 | |
| 206 | 290 | m_latch->write(0); |
| 207 | 291 | m_centronics->write_strobe(1); |
| 208 | 292 | |
| 209 | | m_int2 = 0; |
| 210 | | m_int3 = 0; |
| 211 | 293 | m_fd6 = 0; |
| 212 | 294 | m_fd7 = 0; |
| 295 | m_status = 0; |
| 296 | |
| 297 | check_interrupt(); |
| 213 | 298 | } |
| 214 | 299 | |
| 215 | 300 | |
| r30842 | r30843 | |
| 235 | 320 | bit description |
| 236 | 321 | |
| 237 | 322 | 0 BUSY |
| 238 | | 1 mouse pin 8 |
| 239 | | 2 mouse pin 1 |
| 240 | | 3 mouse pin 2 |
| 241 | | 4 mouse pin 4 flip-flop Q |
| 242 | | 5 mouse pin 3 flip-flop Q |
| 243 | | 6 INT3 |
| 244 | | 7 INT2 |
| 323 | 1 mouse pin 8 (middle button) |
| 324 | 2 mouse pin 1 (right button) |
| 325 | 3 mouse pin 2 (left button) |
| 326 | 4 mouse pin 4 flip-flop Q (Y direction) |
| 327 | 5 mouse pin 3 flip-flop Q (X direction) |
| 328 | 6 INT3 (Y interrupt) |
| 329 | 7 INT2 (X interrupt) |
| 245 | 330 | |
| 246 | 331 | */ |
| 247 | 332 | |
| 248 | | data = m_busy; |
| 249 | | data |= m_int3 << 6; |
| 250 | | data |= m_int2 << 7; |
| 333 | data = m_buttons->read() & 0x0e; |
| 334 | data |= m_status & 0xf1; |
| 251 | 335 | break; |
| 252 | 336 | } |
| 253 | 337 | } |
| r30842 | r30843 | |
| 327 | 411 | |
| 328 | 412 | m_fd6 = BIT(data, 6); |
| 329 | 413 | m_fd7 = BIT(data, 7); |
| 414 | |
| 330 | 415 | check_interrupt(); |
| 331 | 416 | } |
| 332 | 417 | break; |
| r30842 | r30843 | |
| 336 | 421 | break; |
| 337 | 422 | |
| 338 | 423 | case 4: |
| 339 | | m_int2 = 0; |
| 340 | | m_int3 = 0; |
| 424 | m_status &= ~(ST_Y_INT | ST_X_INT); |
| 341 | 425 | check_interrupt(); |
| 342 | 426 | break; |
| 343 | 427 | |
| r30842 | r30843 | |
| 359 | 443 | |
| 360 | 444 | void sandy_superqboard_t::check_interrupt() |
| 361 | 445 | { |
| 362 | | int extint = (m_fd6 && m_busy) || (m_fd7 && (m_int2 || m_int3)); |
| 446 | bool busy_int = m_fd6 && (m_status & ST_BUSY); |
| 447 | bool mouse_int = m_fd7 && (m_status & (ST_Y_INT | ST_X_INT)); |
| 448 | bool extint = busy_int || mouse_int; |
| 363 | 449 | |
| 364 | 450 | m_slot->extintl_w(extint ? ASSERT_LINE : CLEAR_LINE); |
| 365 | 451 | } |
trunk/src/emu/bus/ql/sandy_superqboard.h
| r30842 | r30843 | |
| 2 | 2 | // copyright-holders:Curt Coder, Phill Harvey-Smith |
| 3 | 3 | /********************************************************************** |
| 4 | 4 | |
| 5 | | Sandy SuperQBoard (with HD upgrade) emulation |
| 5 | Sandy SuperQBoard/SuperQMouse (with HD upgrade) emulation |
| 6 | 6 | |
| 7 | 7 | Copyright MESS Team. |
| 8 | 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| r30842 | r30843 | |
| 43 | 43 | |
| 44 | 44 | DECLARE_FLOPPY_FORMATS( floppy_formats ); |
| 45 | 45 | |
| 46 | DECLARE_INPUT_CHANGED_MEMBER( mouse_x_changed ); |
| 47 | DECLARE_INPUT_CHANGED_MEMBER( mouse_y_changed ); |
| 48 | |
| 46 | 49 | protected: |
| 47 | 50 | // device-level overrides |
| 48 | 51 | virtual void device_start(); |
| r30842 | r30843 | |
| 53 | 56 | virtual void write(address_space &space, offs_t offset, UINT8 data); |
| 54 | 57 | |
| 55 | 58 | private: |
| 59 | enum |
| 60 | { |
| 61 | ST_BUSY = 0x01, |
| 62 | ST_MIDDLE = 0x02, |
| 63 | ST_RIGHT = 0x04, |
| 64 | ST_LEFT = 0x08, |
| 65 | ST_Y_DIR = 0x10, |
| 66 | ST_X_DIR = 0x20, |
| 67 | ST_Y_INT = 0x40, |
| 68 | ST_X_INT = 0x80 |
| 69 | }; |
| 70 | |
| 56 | 71 | void check_interrupt(); |
| 57 | 72 | |
| 58 | 73 | required_device<wd1772_t> m_fdc; |
| r30842 | r30843 | |
| 62 | 77 | required_device<output_latch_device> m_latch; |
| 63 | 78 | required_memory_region m_rom; |
| 64 | 79 | optional_shared_ptr<UINT8> m_ram; |
| 80 | optional_ioport m_buttons; |
| 65 | 81 | |
| 66 | 82 | int m_ram_size; |
| 67 | | int m_busy; |
| 68 | | int m_int2; |
| 69 | | int m_int3; |
| 70 | 83 | int m_fd6; |
| 71 | 84 | int m_fd7; |
| 85 | |
| 86 | UINT8 m_status; |
| 72 | 87 | }; |
| 73 | 88 | |
| 74 | 89 | |
| r30842 | r30843 | |
| 82 | 97 | }; |
| 83 | 98 | |
| 84 | 99 | |
| 100 | // ======================> sandy_superqmouse_t |
| 101 | |
| 102 | class sandy_superqmouse_t : public sandy_superqboard_t |
| 103 | { |
| 104 | public: |
| 105 | // construction/destruction |
| 106 | sandy_superqmouse_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 107 | |
| 108 | // optional information overrides |
| 109 | virtual ioport_constructor device_input_ports() const; |
| 110 | }; |
| 111 | |
| 112 | |
| 113 | // ======================> sandy_superqmouse_512k_t |
| 114 | |
| 115 | class sandy_superqmouse_512k_t : public sandy_superqboard_t |
| 116 | { |
| 117 | public: |
| 118 | // construction/destruction |
| 119 | sandy_superqmouse_512k_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 120 | |
| 121 | // optional information overrides |
| 122 | virtual ioport_constructor device_input_ports() const; |
| 123 | }; |
| 124 | |
| 125 | |
| 85 | 126 | // device type definition |
| 86 | 127 | extern const device_type SANDY_SUPERQBOARD; |
| 87 | 128 | extern const device_type SANDY_SUPERQBOARD_512K; |
| 129 | extern const device_type SANDY_SUPERQMOUSE; |
| 130 | extern const device_type SANDY_SUPERQMOUSE_512K; |
| 88 | 131 | |
| 89 | 132 | |
| 133 | |
| 90 | 134 | #endif |