src/mess/drivers/geniusiq.c
| r15653 | r15654 | |
| 91 | 91 | |
| 92 | 92 | #define MACHINE_RESET_MEMBER(name) void name::machine_reset()
|
| 93 | 93 | |
| 94 | #define KEYBOARD_QUEUE_SIZE 8
|
| 95 | |
| 94 | 96 | class geniusiq_state : public driver_device
|
| 95 | 97 | {
|
| 96 | 98 | public:
|
| r15653 | r15654 | |
| 120 | 122 | |
| 121 | 123 | UINT16 m_mouse_posx;
|
| 122 | 124 | UINT16 m_mouse_posy;
|
| 123 | | UINT16 m_input;
|
| 125 | struct
|
| 126 | {
|
| 127 | UINT16 buffer[KEYBOARD_QUEUE_SIZE];
|
| 128 | int head;
|
| 129 | int tail;
|
| 130 | } m_keyboard;
|
| 124 | 131 | };
|
| 125 | 132 | |
| 126 | 133 | |
| r15653 | r15654 | |
| 217 | 224 | |
| 218 | 225 | UINT16 data = 0;
|
| 219 | 226 | |
| 220 | | if(m_input != 0)
|
| 227 | if(m_keyboard.head != m_keyboard.tail)
|
| 221 | 228 | {
|
| 222 | | data = m_input;
|
| 229 | data = m_keyboard.buffer[m_keyboard.head];
|
| 223 | 230 | |
| 231 | m_keyboard.head = (m_keyboard.head+1) % KEYBOARD_QUEUE_SIZE;
|
| 232 | |
| 224 | 233 | data |= (1<<8);
|
| 234 | }
|
| 225 | 235 | |
| 226 | | // TODO: some inputs can be lost during a fast keys sequence, maybe a queue can be the solution
|
| 227 | | m_input = 0;
|
| 236 | if(m_keyboard.head == m_keyboard.tail)
|
| 228 | 237 | m_maincpu->set_input_line(M68K_IRQ_4, CLEAR_LINE);
|
| 229 | | }
|
| 230 | 238 | |
| 231 | 239 | return data;
|
| 232 | 240 | }
|
| 233 | 241 | |
| 234 | 242 | INPUT_CHANGED_MEMBER( geniusiq_state::send_input )
|
| 235 | 243 | {
|
| 236 | | m_input = (UINT8)(FPTR)param;
|
| 244 | m_keyboard.buffer[m_keyboard.tail] = (UINT8)(FPTR)param;
|
| 237 | 245 | |
| 238 | 246 | // set bit 7 if the key is released
|
| 239 | 247 | if (!newval)
|
| 240 | | m_input |= 0x80;
|
| 248 | m_keyboard.buffer[m_keyboard.tail] |= 0x80;
|
| 241 | 249 | |
| 250 | m_keyboard.tail = (m_keyboard.tail+1) % KEYBOARD_QUEUE_SIZE;
|
| 251 | |
| 242 | 252 | // new input from keyboard
|
| 243 | 253 | m_maincpu->set_input_line(M68K_IRQ_4, ASSERT_LINE);
|
| 244 | 254 | }
|
| r15653 | r15654 | |
| 426 | 436 | |
| 427 | 437 | MACHINE_RESET_MEMBER( geniusiq_state )
|
| 428 | 438 | {
|
| 439 | m_keyboard.head = m_keyboard.tail = 0;
|
| 429 | 440 | }
|
| 430 | 441 | |
| 431 | 442 | static MACHINE_CONFIG_START( geniusiq, geniusiq_state )
|